/* public/css/styles.css */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    color: #333;
}

/* --- Header & Layout --- */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header button {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    /* Asegurar que el botón es legible en móvil */
    font-size: 1em; 
}

.pedidos-grid {
    padding: 20px;
    display: grid;
    gap: 20px;
    /* Desktop layout */
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); 
}

/* --- Pedido Card --- */
.pedido-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s;
}

.pedido-card:hover {
    transform: translateY(-2px);
}

.pedido-card h3 {
    margin-top: 0;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

.pedido-meta {
    font-size: 0.9em;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

/* Retrasado */
.pedido-card.delayed {
    border: 3px solid var(--danger-color);
    background-color: #ffeaea;
}

.timer-box {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary-color);
    margin: 10px 0;
    display: flex;
    align-items: center;
}
.timer-delayed {
    color: var(--danger-color);
}
.timer-icon {
    margin-right: 5px;
}

/* --- Item List --- */
.item-list {
    list-style: none;
    padding: 0;
}

.item-list li {
    padding: 10px 0;
    border-bottom: 1px dashed var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    /* Añadido para mejor control en el flujo móvil */
    position: relative; 
}
.item-list li:last-child {
    border-bottom: none;
}

.item-quantity {
    font-weight: bold;
    margin-right: 5px;
    color: var(--primary-color);
}

.item-comment {
    font-style: italic;
    color: var(--secondary-color);
    font-size: 0.9em;
    /* Ajuste para que se muestre debajo del nombre si hay poco espacio */
    flex-basis: 100%;
    order: 4; 
    margin-top: 5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: bold;
    margin-left: 5px;
    text-transform: uppercase;
}
.item-destination.barra { background-color: #33ccff; color: #000; }
.item-destination.cocina { background-color: #ff9933; color: #000; }
.item-destination.ambos { background-color: #cc66ff; color: #fff; }
.delayed-badge { background-color: var(--danger-color); color: white; margin-bottom: 5px; }

/* Item Status */
.item-status { 
    font-weight: bold; 
    margin-left: auto; /* Mueve el estado a la derecha en escritorio */
}
.item-status.pending { color: var(--secondary-color); }
.item-status.preparing { color: var(--warning-color); }
.item-status.ready { color: var(--success-color); }
.item-status.served { color: #008000; } /* Servido: Verde más oscuro */
.item-status.cancelled { color: var(--danger-color); }
.item-status.delayed { color: var(--danger-color); }


/* --- Item Actions --- */
.item-actions {
    margin-top: 5px;
    width: 100%;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}
.btn-action {
    padding: 8px 10px; /* Aumentar el padding para facilitar el toque */
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em; /* Ligeramente más grande */
    transition: background-color 0.2s;
    flex-grow: 1;
    /* Permitir que se dividan en dos columnas si hay 3 o 4 botones */
    min-width: 100px; 
}

.btn-action.preparing { background-color: #007bff; color: white; }
.btn-action.ready { background-color: #28a745; color: white; }
.btn-action.served { background-color: #17a2b8; color: white; }
.btn-action[disabled] { opacity: 0.6; cursor: not-allowed; }

.complete-pedido {
    background-color: var(--secondary-color);
    color: white;
    padding: 10px;
    width: 100%;
    border: none;
    border-radius: 4px;
    margin-top: 15px;
    cursor: pointer;
}

/* --- Login Page --- */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.login-form button {
    width: 100%;
    padding: 10px;
    background-color: var(--success-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
}

/* ---------------------------------------------------- */
/* --- Responsive (Mobile) OPTIMIZACIÓN CLAVE --- */
/* ---------------------------------------------------- */
@media (max-width: 768px) {
    
    /* Layout principal */
    .pedidos-grid {
        grid-template-columns: 1fr; /* Tarjetas apiladas */
        padding: 10px;
    }
    .pedido-card {
        padding: 15px;
    }
    
    /* Ajustes del encabezado */
    header h1 {
        font-size: 1.5em;
    }

    /* Distribución de Items de Pedido */
    .item-list li {
        /* Permite que los elementos se apilen de forma controlada */
        flex-direction: row; 
        flex-wrap: wrap; 
        align-items: flex-start;
        padding: 10px 0;
    }
    
    /* Nombre y Cantidad */
    .item-quantity {
        font-size: 1.1em;
    }
    .item-name {
        /* Asegura que el nombre ocupe el espacio restante en la línea */
        flex-grow: 1; 
        font-size: 1em;
        margin-right: 5px;
        order: 2; /* Cantidad (1), Nombre (2), Destino/Estado (3, 4) */
    }
    
    /* Estado y Destino (Moverlos a la derecha) */
    .item-destination, .item-status {
        font-size: 0.8em;
        margin-top: 5px;
        flex-basis: auto;
    }
    .item-status {
        order: 4;
        margin-left: 10px;
    }
    .item-destination {
        order: 3;
        margin-left: 0;
    }
    
    /* Comentarios debajo de todo */
    .item-comment {
        font-size: 0.85em;
        order: 5;
        margin-top: 5px;
        padding-top: 5px;
        border-top: 1px dashed var(--border-color);
    }
    
    /* Botones de acción */
    .item-actions {
        margin-top: 10px;
        /* Asegura que los botones ocupen el ancho completo y se apilen si es necesario */
        flex-wrap: wrap; 
        gap: 8px;
    }
    .btn-action {
        /* Fuerza los botones a ocupar aproximadamente el 50% para tener dos por fila */
        flex-basis: calc(50% - 4px); 
        min-width: unset;
        font-size: 0.9em;
    }
    /* Si solo hay 1 botón, que ocupe el 100% */
    .item-actions:only-child .btn-action {
        flex-basis: 100%;
    }
}

.empty-state {
    grid-column: 1 / -1; /* Ocupa todo el ancho */
    text-align: center;
    padding: 50px;
    font-size: 1.2em;
    color: var(--secondary-color);
    background-color: #fff;
    border-radius: 8px;
}