:root {
    --color-primary: #007aff;
    --color-secondary: #f0f0f0;
    --color-text: #333;
    --color-bg: #f9f9f9;
    --color-white: #ffffff;
    --border-radius: 12px;
    --box-shadow: 0 4px 16px rgba(0,0,0,0.07);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

body.auth-active {
    background-color:rgba(0,122,255,0.1);
}

.auth-active img {
    width: 250px;
    margin-bottom: 3rem;
}

body:not(.auth-active) {
    padding-bottom: 70px;
}

.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    width: 100%;
}

#auth-container {
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

#app-container {
    padding-bottom: 2rem;
}

.auth-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2.5rem;
}

.auth-header .logo {
    color: var(--color-primary);
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
}

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #000;
    margin: 0 0 0.25rem 0;
}

.auth-header p {
    font-size: 1rem;
    color: #555;
    margin: 0;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
}
.app-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #000;
    margin: 0;
}
.app-header .btn-link-logout {
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.25rem 0;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

h2, h3 {
    text-align: center;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

fieldset {
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

legend {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    width: 100%;
    color: #000;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #444;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="datetime-local"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    background-color: #fdfdfd;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-white);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

textarea {
    resize: vertical;
}

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 4px 12px rgba(0,122,255,0.2);
}

.btn-primary:hover {
    background-color: #006ae6;
}
.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,122,255,0.2);
}

.btn-secondary {
    background-color: var(--color-white);
    color: var(--color-text);
    border: 1px solid #e0e0e0;
}
.btn-secondary:hover {
    background-color: #f7f7f7;
    border-color: #d0d0d0;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    color: var(--color-text);
}

#product-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid #f0f0f0;
    border-radius: var(--border-radius);
    background: var(--color-white);
}
.product-item label {
    font-weight: 500;
}
.product-item .price {
    font-size: 0.9rem;
    color: #555;
    margin-left: 0.5rem;
}
.product-item input[type="number"] {
    width: 60px;
    padding: 0.5rem;
    text-align: center;
}

.total-display {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: right;
    margin-bottom: 0.5rem;
}
#total-price {
    color: var(--color-primary);
}

#order-status-container {
    margin-top: 1rem;
    padding: 1.25rem;
    background-color: var(--color-white);
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}
#status-content {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
}
#order-details-list {
    list-style-type: none;
    padding-left: 0;
    font-size: 0.9rem;
    color: #444;
}
#order-details-list li {
    padding: 0.25rem 0;
}

.hidden {
    display: none !important;
}

.view-switcher {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.btn-link {
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-bottom: 2px solid transparent;
}

.btn-link:hover {
    color: #0056b3;
}

.btn-link.active {
    border-bottom-color: var(--color-primary);
}

#my-orders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.order-list-item {
    padding: 1.25rem;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    background-color: var(--color-white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.order-list-item h4 {
    margin-bottom: 0.5rem;
    color: var(--color-primary);
    font-weight: 600;
}

.order-list-item p {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.order-list-item strong {
    font-weight: 600;
    color: #222;
}

.form-error {
    color: #D8000C;
    background-color: #FFD2D2;
    padding: 0.85rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid #D8000C;
}

.auth-toggle {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-toggle .btn-link {
    font-size: 0.9rem;
    padding: 0;
    vertical-align: baseline;
}

.btn-link-logout {
    color: #D8000C;
    font-weight: 500;
    padding: 0.25rem;
}
.btn-link-logout:hover {
    color: #a00;
}

input[readonly] {
    background-color: #f4f4f4;
    color: #555;
    cursor: not-allowed;
    border-color: #eee;
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: capitalize;
    border: 1px solid transparent;
}

.status-pending {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeeba;
}

.status-active {
    color: #004085;
    background-color: #cce5ff;
    border-color: #b8daff;
}

.status-shipping {
    color: #581c87;
    background-color: #f3e8ff;
    border-color: #e9d5ff;
}

.status-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.status-failed {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    width: 100%;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-secondary);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.countdown {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-primary);
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: #f0f8ff;
    border-radius: var(--border-radius);
    border: 1px solid #bde0ff;
}

#my-orders-list .order-list-item {
    cursor: pointer; 
    transition: background-color 0.2s, box-shadow 0.2s;
}

#my-orders-list .order-list-item:hover {
    background-color: #fcfcfc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.order-list-countdown {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-primary);
    margin-top: 0.25rem;
}

.order-list-countdown.delayed {
    color: #D8000C;
}

.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-filter {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    background-color: var(--color-white);
    color: var(--color-primary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.btn-filter:hover {
    background-color: #f0f8ff;
}

.btn-filter.active {
    background-color: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
}

#my-history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#my-history-list .order-list-item {
    cursor: default;
    background-color: var(--color-white);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border: 1px solid #eee;
}

#my-history-list .order-list-item:hover {
    background-color: var(--color-white);
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr); 
    gap: 1rem;
    margin-bottom: 2rem;
}

.summary-card {
    background-color: var(--color-white);
    padding: 1.25rem 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    text-align: center;
    border: 1px solid #f0f0f0;
}

.summary-card h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-card.full-width {
    grid-column: 1 / -1;
}
.summary-card.full-width p {
    font-size: 1.25rem;
}

.chart-container {
    background-color: var(--color-white);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
    border: 1px solid #f0f0f0;
}

.history-list-title {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: left;
    margin-bottom: 1rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--color-secondary);
    color: #000;
}

.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    background-color: var(--color-white);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    border-top: 1px solid #eee;
    z-index: 1000;
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    cursor: pointer;
    color: #888;
    background: none;
    border: none;
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-btn svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.15rem;
    fill: #888;
    transition: fill 0.2s;
}

.nav-btn:hover {
    color: #333;
}
.nav-btn:hover svg {
    fill: #333;
}

.nav-btn.active {
    color: var(--color-primary);
}
.nav-btn.active svg {
    fill: var(--color-primary);
}

.form-success {
    color: #155724;
    background-color: #d4edda;
    padding: 0.85rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid #c3e6cb;
}

select {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid #e0e0e0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    background-color: #fdfdfd;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23555' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 16px 16px;
}

select:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--color-white);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

/* --------------------------------- */
/* --- DIFERENCIACIÓN ROL COLMADO --- */
/* --------------------------------- */

:root {
    /* Define el color para colmados (ej. un verde) */
    --color-colmado: #28a745;
}

/* Cambia el color del header */
body.rol-colmado .app-header {
    background-color: var(--color-colmado);
    margin: 0 -1.5rem 1.5rem -1.5rem;
    padding: 1rem 1.5rem;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.2);
}

body.rol-colmado .app-header h2 {
    color: var(--color-white);
}

body.rol-colmado .app-header .btn-link-logout {
    color: var(--color-white);
    background: rgba(255,255,255,0.15);
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius);
}
body.rol-colmado .app-header .btn-link-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* Cambia el color de la barra de navegación */
body.rol-colmado .app-nav {
    border-top-color: var(--color-colmado);
    box-shadow: 0 -2px 10px rgba(40, 167, 69, 0.1);
}

body.rol-colmado .nav-btn.active {
    color: var(--color-colmado);
}
body.rol-colmado .nav-btn.active svg {
    fill: var(--color-colmado);
}

/* Estilo para el Badge del Header */
#header-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-white);
    background-color: rgba(255,255,255,0.2);
    padding: 0.15rem 0.5rem;
    border-radius: 8px;
    margin-top: 0.25rem;
    display: inline-block;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--color-white);
    border-radius: var(--border-radius);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-secondary);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: left;
}

.btn-modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    font-weight: 400;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.btn-modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-info-group {
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.7;
}
.modal-info-group p {
    margin: 0.25rem 0;
}

.modal-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.25rem;
}

.modal-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.95rem;
}
.modal-items-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f9f9f9;
}
.modal-items-list li:last-child {
    border-bottom: none;
}
.modal-items-list .item-precio {
    color: #555;
}

/* --- ESTILOS DE HISTORIAL --- */
#my-history-list .order-list-item {
    cursor: pointer; /* <-- ¡IMPORTANTE! */
    transition: background-color 0.2s, box-shadow 0.2s;
}

#my-history-list .order-list-item:hover {
    background-color: #fcfcfc;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}





.app-header {
    /* Reemplaza justify-content por space-between */
    justify-content: space-between;
    align-items: center;
    /* Asegura que los 3 elementos se alineen bien */
    display: flex;
}

.header-title-group {
    /* Esto centra el título */
    flex: 1;
    text-align: center;
    /* Ajuste por si el título es muy largo */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* El título dentro del grupo */
.app-header h2 {
    margin: 0;
    display: inline-block; /* Permite que el badge se alinee */
}

/* El badge dentro del grupo */
#header-badge {
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* Botones de acción (Volver y Salir) */
.btn-back,
.app-header .btn-link-logout {
    /* Define un ancho fijo para que el centrado sea perfecto */
    flex-basis: 50px;
    padding: 0;
    margin: 0;
    text-align: center;
}

/* Estilo específico para el botón de Salir */
.app-header .btn-link-logout {
    text-align: right; /* Alinea el texto de "Salir" a la derecha */
    flex-basis: auto; /* Deja que "Salir" tome su ancho natural */
    padding: 0.25rem 0; /* Restaura su padding original */
}

/* El nuevo botón de flecha */
.btn-back {
    background: rgba(0,0,0,0.05);
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text);
    transition: background-color 0.2s;
}

.btn-back:hover {
    background: rgba(0,0,0,0.1);
}

.btn-back svg {
    width: 22px;
    height: 22px;
    stroke: var(--color-text);
    /* truco para centrar el icono de flecha */
    transform: translateX(-1px);
}

/* --- AJUSTES PARA ROL COLMADO --- */
body.rol-colmado .app-header {
    /* (los estilos existentes están bien) */
}

/* El título en modo colmado */
body.rol-colmado .header-title-group h2 {
    color: var(--color-white);
}

/* La flecha en modo colmado */
body.rol-colmado .btn-back {
    background: rgba(255,255,255,0.15);
}
body.rol-colmado .btn-back:hover {
    background: rgba(255,255,255,0.3);
}
body.rol-colmado .btn-back svg {
    stroke: var(--color-white);
}

/* El botón de salir en modo colmado */
body.rol-colmado .app-header .btn-link-logout {
    /* (los estilos existentes ya lo hacen blanco, está bien) */
}

#auth-container {
    /* Hacemos este el contenedor de posición */
    position: relative;
    /* Añadimos padding superior para el nuevo header fijo.
      Ajustamos el padding-top de 2rem a 4.5rem (aprox 70px)
      para dar espacio al nuevo header.
    */
    padding-top: 4.5rem; 
    padding-bottom: 2rem;
}

.auth-nav-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    /* Calcula el ancho completo menos el padding lateral del container,
      para que el borde inferior llegue a los extremos.
    */
    width: 100%;
    height: 54px; /* Altura estándar de header */
    padding: 0 1.5rem; /* Coincide con el padding de .container */
    border-bottom: 1px solid var(--color-secondary);
    background: var(--color-white);
    
    /* Asegura que esté centrado si .container es más ancho */
    max-width: 400px; 
    margin: 0 auto;
    box-sizing: border-box; /* Importante para el padding */
}

/* Usamos el mismo botón de volver de la app */
.auth-nav-header .btn-back {
    margin: 0;
}

.auth-nav-title {
    flex: 1;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
    /* Movemos el título un poco a la izquierda para
      compensar el botón de volver y que se vea centrado
    */
    padding-right: 40px; /* Ancho del .btn-back */
}

/* Ajustes para el header de "Bienvenido" */
#auth-branding-header {
    /* Quitamos el padding superior que ahora está en #auth-container */
    padding-top: 0;
    margin-bottom: 2rem; /* Reducimos un poco el margen */
}

/* Ajustes para los formularios */
#login-form, #register-form {
    /* Reducimos el gap que ahora está compensado por el padding */
    gap: 1.25rem;
}

























