/* ============================================
   RESET Y BASE
   ============================================ */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* El fondo se aplica según la clase condicional (.body-login o .body-logueado) */
}

/* ============================================
   FONDOS CONDICIONALES
   ============================================ */

/* Fondo para el DASHBOARD (usuario logueado) - gradiente morado */
.body-logueado {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Fondo para LOGIN/REGISTRO - imagen de la Posta Central + overlay */
.body-login {
    position: relative;
    background: url('../img/fondo-posta.webp') center/cover no-repeat fixed;
    background-color: #667eea; /* Fallback si la imagen no carga */
}

/* Overlay semitransparente encima de la imagen para que el texto se lea */
.body-login::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.80) 0%, 
        rgba(118, 75, 162, 0.80) 100%);
    z-index: 0;
}

/* Asegurar que el contenido esté por encima del overlay */
.body-login .container {
    position: relative;
    z-index: 1;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.container {
    width: 100%;
    max-width: 640px;
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* ============================================
   TARJETA PRINCIPAL
   ============================================ */
.card {
    background: white;
    border-radius: 18px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
    width: 100%;
    padding: 35px 30px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tarjeta con efecto "vidrio esmerilado" en login (opcional, se ve elegante sobre la imagen) */
.body-login .card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

h2 {
    text-align: center;
    color: #2d3748;
    margin-bottom: 25px;
    font-size: 22px;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group { 
    margin-bottom: 15px; 
    flex: 1; 
}

.form-row { 
    display: flex; 
    gap: 12px; 
    flex-wrap: wrap; 
}

label {
    display: block;
    margin-bottom: 6px;
    color: #4a5568;
    font-weight: 600;
    font-size: 13px;
}

input, select {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.25s;
    background: #f7fafc;
}

input:focus, select:focus {
    border-color: #667eea;
    background: white;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.12);
}

input.rut-valido { 
    border-color: #38a169 !important; 
    background: #f0fff4; 
}

input.rut-invalido { 
    border-color: #e53e3e !important; 
    background: #fff5f5; 
}

/* ============================================
   BOTONES
   ============================================ */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 13px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    transition: all 0.25s;
    letter-spacing: 0.3px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

button:active { 
    transform: translateY(0); 
}

.btn-danger { 
    background: #e53e3e; 
    background-image: none; 
}

.btn-danger:hover { 
    background: #c53030; 
    box-shadow: 0 8px 20px rgba(229, 62, 62, 0.3); 
}

.btn-sm { 
    width: auto; 
    padding: 8px 16px; 
    font-size: 14px; 
    margin: 0; 
}

.toggle-link {
    text-align: center;
    margin-top: 18px;
    color: #667eea;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
}

.toggle-link:hover { 
    color: #5a67d8; 
    text-decoration: underline; 
}

.hidden { 
    display: none !important; 
}

/* ============================================
   MENSAJES
   ============================================ */
.error { 
    color: #e53e3e; 
    font-size: 13px; 
    margin-top: 6px; 
    min-height: 18px; 
}

.success { 
    color: #38a169; 
    font-size: 14px; 
    margin-top: 10px; 
    text-align: center; 
    font-weight: 600; 
}

.hint { 
    color: #718096; 
    font-size: 12px; 
    margin-top: 4px; 
    min-height: 16px; 
}

/* ============================================
   DASHBOARD
   ============================================ */
.header-dashboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 15px;
    margin-bottom: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.user-info { 
    font-size: 15px; 
    color: #4a5568; 
}

.user-info span { 
    font-weight: 700; 
    color: #667eea; 
}

.titulo-pedido { 
    margin-bottom: 5px !important; 
    font-size: 20px !important; 
}

.subtitulo-pedido {
    text-align: center;
    color: #718096;
    font-size: 13px;
    margin-bottom: 20px;
}

/* ============================================
   TARJETAS DE GAS
   ============================================ */
.gas-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.gas-card {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.25s;
    background: #f7fafc;
}

.gas-card:hover {
    border-color: #667eea;
    background: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.gas-info { 
    flex: 1; 
    min-width: 0; 
}

.gas-card h3 {
    color: #2d3748;
    font-size: 14px;
    margin-bottom: 3px;
    font-weight: 700;
}

.gas-card .precio { 
    font-size: 15px; 
    color: #38a169; 
    font-weight: 700; 
}

.gas-card input {
    width: 60px !important;
    padding: 8px !important;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
    background: white;
}

/* ============================================
   TOTAL
   ============================================ */
.total-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 17px;
    font-weight: 700;
    color: #2d3748;
    margin: 15px 0 20px;
    padding: 15px 20px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 12px;
    border-left: 4px solid #667eea;
}

.total-section span:last-child { 
    color: #667eea; 
    font-size: 22px; 
}

.btn-pedido { 
    margin-top: 15px; 
    padding: 14px; 
    font-size: 16px; 
}

/* ============================================
   HISTORIAL DE PEDIDOS
   ============================================ */
.historial-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #f0f2f5;
}

.historial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.historial-header h3 { 
    color: #2d3748; 
    font-size: 17px; 
    font-weight: 700; 
}

.btn-refresh {
    width: auto;
    padding: 6px 12px;
    margin: 0;
    background: #edf2f7;
    background-image: none;
    color: #4a5568;
    font-size: 14px;
    border-radius: 8px;
}

.btn-refresh:hover { 
    background: #e2e8f0; 
    transform: rotate(45deg); 
    box-shadow: none; 
}

.historial-lista {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.historial-vacio {
    text-align: center;
    color: #a0aec0;
    padding: 30px 15px;
    background: #f7fafc;
    border-radius: 12px;
    font-size: 14px;
}

.pedido-item {
    background: #f7fafc;
    border: 2px solid #edf2f7;
    border-radius: 12px;
    padding: 14px 16px;
    transition: all 0.25s;
}

.pedido-item:hover {
    border-color: #667eea;
    background: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.pedido-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.pedido-fecha { 
    font-size: 12px; 
    color: #718096; 
    font-weight: 600; 
}

.pedido-estado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Estados del pedido */
.estado-esperando_validacion { 
    background: #feebc8; 
    color: #7b341e; 
}

.estado-transferencia_verificada { 
    background: #bee3f8; 
    color: #2a4365; 
}

.estado-en_camino { 
    background: #c6f6d5; 
    color: #22543d; 
}

.estado-entregado { 
    background: #c6f6d5; 
    color: #22543d; 
    border: 1px solid #38a169; 
}

.pedido-productos {
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 8px;
    line-height: 1.5;
}

.pedido-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px dashed #e2e8f0;
    gap: 8px;
}

.pedido-total { 
    font-size: 16px; 
    font-weight: 700; 
    color: #38a169; 
}

.btn-ver-comprobante {
    width: auto;
    margin: 0;
    padding: 6px 12px;
    font-size: 12px;
    background: #667eea;
    background-image: none;
    border-radius: 8px;
}

.btn-ver-comprobante:hover { 
    background: #5a67d8; 
    box-shadow: none; 
    transform: none; 
}

/* ============================================
   PANTALLA DE ÉXITO (pedido-exitoso.php)
   ============================================ */
.exito-card { 
    text-align: center; 
    padding: 45px 35px; 
}

.exito-icono { 
    font-size: 80px; 
    margin-bottom: 20px; 
    animation: popIn 0.5s ease; 
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.exito-titulo {
    color: #38a169 !important;
    font-size: 24px !important;
    margin-bottom: 20px !important;
}

.exito-detalle { 
    font-size: 16px; 
    color: #4a5568; 
    margin-bottom: 10px; 
}

.exito-detalle strong { 
    color: #667eea; 
    font-size: 20px; 
}

.exito-info {
    background: #f7fafc;
    border-left: 4px solid #667eea;
    border-radius: 10px;
    padding: 18px 20px;
    margin: 25px 0;
    text-align: left;
}

.exito-info p {
    color: #4a5568;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.5;
}

.exito-info p:last-child { 
    margin-bottom: 0; 
}

.exito-redirect {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 25px 0;
    font-size: 14px;
    color: #718096;
    flex-wrap: wrap;
}

.contador {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 20px;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .card { 
        padding: 25px 20px; 
    }
    .gas-grid { 
        grid-template-columns: 1fr; 
    }
    .form-row { 
        flex-direction: column; 
        gap: 0; 
    }
    .header-dashboard { 
        flex-direction: column; 
        align-items: stretch; 
    }
    .btn-sm { 
        width: 100%; 
    }
    h2 { 
        font-size: 20px; 
    }
}