/* css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* BLOQUEO DE DESBORDAMIENTO: Evita que la pantalla se mueva a los lados */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: #f4f7f6;
    color: #333;
    display: block !important;
    min-height: 100vh;
}

/* =========================================================
   1. ESTILOS BASE Y COMPONENTES (Botones, inputs, msjs)
   ========================================================= */
.form-group { margin-bottom: 15px; width: 100%; }
.form-group label { display: block; margin-bottom: 8px; font-weight: bold; color: #555; font-size: 14px;}
.form-group input, .form-group select, .form-group textarea { 
    width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 15px; box-sizing: border-box;
}

.btn-login {
    width: 100%; padding: 12px; background-color: #3498db; color: white; border: none;
    border-radius: 5px; font-size: 16px; cursor: pointer; transition: background 0.3s; margin-top: 10px; font-weight: bold;
    box-sizing: border-box;
}
.btn-login:hover { background-color: #2980b9; }

.error-msg { color: #e74c3c; text-align: center; margin-bottom: 15px; font-size: 14px; background-color: #fadbd8; padding: 10px; border-radius: 5px; font-weight: bold;}
.success-msg { color: #27ae60; background-color: #e8f8f5; padding: 10px; border-radius: 5px; margin-bottom: 15px; text-align: center; font-weight: bold;}

/* Tablas generales (PC) */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table th, table td { border: 1px solid #ddd; padding: 12px; text-align: left; font-size: 14px;}
table th { background-color: #3498db; color: white; }
table tr:nth-child(even) { background-color: #f9f9f9; }

/* Buscador */
.search-bar { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #ccc; border-radius: 5px; font-size: 16px; box-sizing: border-box; }

/* Animaciones y Pestañas */
.vista-seccion { display: none; }
.vista-seccion.activa { display: block; animation: fadeIn 0.3s ease-in-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   2. ESTRUCTURA PRINCIPAL (DASHBOARD LAYOUT)
   ========================================================= */
.admin-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    width: 100%;
}

/* Menú Lateral */
.sidebar {
    width: 250px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .logo-container { text-align: center; padding: 20px 10px; background-color: #1a252f; border-bottom: 2px solid #3498db; }
.sidebar .logo-container img { max-width: 80%; height: auto; max-height: 120px; border-radius: 5px; object-fit: contain; }
.sidebar a { padding: 15px 20px; color: #ecf0f1; text-decoration: none; border-bottom: 1px solid #34495e; transition: 0.3s; cursor: pointer; }
.sidebar a:hover, .sidebar a.activo { background-color: #34495e; border-left: 4px solid #3498db; }
.sidebar .btn-salir { margin-top: auto; background-color: #c0392b; text-align: center; border: none; }
.sidebar .btn-salir:hover { background-color: #e74c3c; border-left: none; }

/* Contenido Principal */
.main-content {
    flex: 1;
    padding: 30px;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Tarjetas de Métricas */
.metric-cards { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.metric-card { background: white; padding: 20px; border-radius: 8px; flex: 1; min-width: 200px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); border-bottom: 4px solid #3498db; }
.metric-card.verde { border-bottom-color: #27ae60; }
.metric-card.naranja { border-bottom-color: #f39c12; }
.metric-card h4 { color: #7f8c8d; font-size: 14px; margin-top: 0; margin-bottom: 10px; }
.metric-card p { font-size: 26px; font-weight: bold; color: #2c3e50; margin: 0; }

/* =========================================================
   3. ESTILOS ESPECÍFICOS DEL ADMINISTRADOR
   ========================================================= */
.btn-accion { padding: 6px 12px; text-decoration: none; border-radius: 4px; display: inline-block; font-size: 13px; color: white; font-weight: bold; margin-bottom: 5px;}
.btn-aprobar { background-color: #27ae60; }
.btn-rechazar { background-color: #e74c3c; }

.grid-bancos { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 15px; }
.banco-card { background: #fdfdfd; padding: 20px; border-radius: 8px; border: 1px solid #e0e0e0; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.banco-card h4 { margin-top: 0; color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; margin-bottom: 15px; font-size: 16px; }

.prod-img { width: 50px; height: 50px; object-fit: cover; border-radius: 5px; border: 1px solid #ddd; }

/* =========================================================
   4. ESTILOS ESPECÍFICOS DEL CLIENTE
   ========================================================= */
.beneficios { background: #fff3cd; border-left: 5px solid #ffc107; padding: 15px; margin-bottom: 20px; border-radius: 4px; }
.tarjeta-cuota { background: white; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); margin-bottom: 20px; border-left: 5px solid #3498db; overflow: hidden; }
.tarjeta-pagada { border-left-color: #27ae60; }
.tarjeta-header { padding: 15px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; background: #fafafa;}
.tarjeta-header h4 { margin: 0; color: #2c3e50; font-size: 16px;}
.tarjeta-header .monto { font-size: 20px; font-weight: bold; color: #2c3e50;}
.tarjeta-body { padding: 15px; }
.info-historial { background: #fdfdfd; padding: 10px 15px; display: flex; justify-content: space-between; font-size: 13px; color: #555; border-top: 1px dashed #ddd; }
.alerta-rechazo { background-color: #fadbd8; border-left: 4px solid #c0392b; padding: 12px; margin-bottom: 15px; border-radius: 4px; }
.etiqueta-revision { background-color: #f39c12; color: white; padding: 6px 10px; border-radius: 4px; font-size: 14px; display: block; text-align: center; margin-top: 15px; font-weight: bold;}
.datos-bancarios { background: #e8f8f5; padding: 15px; border-radius: 4px; color: #16a085; display: none; font-size: 14px; line-height: 1.5; border-left: 4px solid #1abc9c; margin-bottom: 10px;}
.form-pago { background: #fdfdfd; padding: 15px; border-radius: 5px; margin-top: 15px; display: flex; flex-direction: column; gap: 10px; border: 1px solid #e0e0e0;}

/* =========================================================
   5. ESTILOS DE ASIGNAR CRÉDITO Y PERFILES
   ========================================================= */
.venta-layout { width: 100%; max-width: 650px; margin: 40px auto; background: transparent; padding: 0 15px; box-sizing: border-box;}
.venta-header { text-align: center; margin-bottom: 20px; }
.venta-header img { max-width: 150px; border-radius: 8px; margin-bottom: 10px; }
.venta-card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.venta-card h2 { margin-top: 0; color: #2c3e50; font-size: 22px; text-align: center; border-bottom: 2px solid #3498db; padding-bottom: 15px; }
.cliente-info { background: #e8f8f5; border-left: 4px solid #1abc9c; padding: 15px; border-radius: 4px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center;}
.cliente-info p { margin: 0; color: #2c3e50; }
.cliente-info .disponible { font-size: 22px; font-weight: bold; color: #27ae60; }
.toggle-box { background: #fdfdfd; border: 1px solid #eee; padding: 15px; border-radius: 8px; margin-bottom: 15px;}
.radio-group { display: flex; gap: 20px; margin-bottom: 15px; font-weight: bold; color: #34495e; }
.preview-box { display: none; background: #fdfdfd; border: 2px dashed #3498db; padding: 20px; border-radius: 8px; margin-top: 20px; animation: fadeIn 0.3s ease-in-out; }
.preview-box h4 { margin-top: 0; color: #2980b9; font-size: 16px; text-align: center; margin-bottom: 15px; }
.preview-item { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 15px; color: #34495e; }
.preview-total { border-top: 1px solid #eee; padding-top: 10px; margin-top: 10px; font-size: 18px; font-weight: bold; color: #2c3e50; text-align: center; }
.btn-acciones { display: flex; gap: 10px; margin-top: 25px; flex-wrap: wrap;}
.btn-guardar { flex: 1; background-color: #27ae60; color: white; border: none; padding: 15px; font-size: 16px; font-weight: bold; border-radius: 6px; cursor: pointer;}
.btn-cancelar { flex: 1; background-color: #95a5a6; color: white; text-align: center; padding: 15px; font-size: 16px; font-weight: bold; border-radius: 6px; text-decoration: none; box-sizing: border-box;}

.perfil-container { width: 100%; max-width: 1000px; margin: 0 auto; background: transparent; padding: 20px 15px; box-sizing: border-box;}
.header-perfil { background: #2c3e50; color: white; padding: 20px; border-radius: 8px 8px 0 0; display: flex; justify-content: space-between; align-items: center; }
.header-perfil h2 { margin: 0; font-size: 22px; }
.cuerpo-perfil { background: white; padding: 20px; border-radius: 0 0 8px 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: bold; color: white; }
.badge.pendiente { background-color: #e74c3c; }
.badge.reportado { background-color: #f39c12; }
.badge.pagada { background-color: #27ae60; }
.box-info { background: #fdfdfd; padding: 15px; border-radius: 5px; border: 1px solid #ddd; }


/* =========================================================
   6. PANTALLA DE LOGIN (INDEX)
   ========================================================= */
.login-page-body {
    background: linear-gradient(135deg, #f4f7f6 0%, #e8f8f5 100%);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.login-wrapper {
    display: flex; flex-direction: row; background: white; border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1); overflow: hidden; max-width: 900px; width: 90%; margin: 20px;
}
.login-info { background-color: #1a252f; color: white; padding: 40px; flex: 1; display: flex; flex-direction: column; justify-content: center; border-right: 5px solid #3498db; }
.login-info img { max-width: 180px; margin-bottom: 20px; border-radius: 10px; }
.login-info h1 { margin-top: 0; color: #3498db; font-size: 28px; }
.login-info p { font-size: 16px; color: #bdc3c7; margin-bottom: 20px; }
.login-info ul { list-style: none; padding: 0; margin: 0; }
.login-info ul li { margin-bottom: 15px; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.login-form-box { padding: 40px; flex: 1; display: flex; flex-direction: column; justify-content: center; background-color: #ffffff; box-sizing: border-box;}


/* =========================================================
   7. RESPONSIVE (MAGIA ESTRICTA PARA CELULARES)
   ========================================================= */
@media (max-width: 768px) {
    /* Mantiene todo dentro de la pantalla 100% */
    .admin-layout { flex-direction: column; width: 100vw; max-width: 100vw; overflow-x: hidden; }
    
    /* El menú no se desborda y se divide en 2 items por fila */
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
    .sidebar .logo-container, .sidebar > div { width: 100%; padding: 10px; box-sizing: border-box; }
    .sidebar .logo-container img { max-height: 55px !important; }
    
    .sidebar a {
        flex: 1 1 45%; 
        text-align: center; 
        font-size: 13px;
        padding: 10px 5px; 
        border-bottom: 2px solid #34495e; 
        border-left: none !important; 
        white-space: normal; 
        word-wrap: break-word;
        box-sizing: border-box;
    }
    .sidebar a:hover, .sidebar a.activo { border-bottom: 3px solid #3498db; background-color: #34495e;}
    .sidebar .btn-salir { flex: 1 1 100%; margin-top: 0; }

    /* Ajuste del contenido principal y su título */
    .main-content { padding: 15px; width: 100%; max-width: 100vw; box-sizing: border-box; overflow-x: hidden;}
    
    .main-content > div:first-child {
        flex-direction: column !important; 
        align-items: flex-start !important;
        gap: 8px;
    }
    .main-content > div:first-child h2 { font-size: 20px; margin: 0; }

    /* Los formularios y tarjetas a 1 sola columna */
    .grid-bancos, form[style*="display: flex"], .grid-2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px;
        width: 100%;
    }
    
    form[style*="display: flex"] > div, .banco-card, .form-group input, .form-group select, button, .btn-guardar, .btn-cancelar {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important; 
        box-sizing: border-box;
    }

    /* ========================================================
       MAGIA: CONVERTIR TABLAS EN "TARJETAS" EN EL CELULAR
       ======================================================== */
    table, thead, tbody, th, td, tr { 
        display: block; 
        width: 100%; 
        box-sizing: border-box;
    }
    
    /* Ocultamos los títulos de las columnas (ID, Nombre, etc.) */
    thead tr { 
        display: none; 
    }
    
    /* Cada cliente/producto es ahora una tarjeta con borde */
    tr { 
        margin-bottom: 20px; 
        border: 2px solid #3498db; 
        border-radius: 10px; 
        box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
        background-color: #fff; 
    }
    
    /* Los datos se ponen uno debajo del otro, centrados elegantemente */
    td { 
        border: none; 
        border-bottom: 1px solid #eee; 
        padding: 12px 15px !important; 
        text-align: center !important; 
        white-space: normal !important; /* Permite saltos de línea */
        word-wrap: break-word;
    }
    
    /* Fondo ligeramente distinto para el área de los botones */
    td:last-child { 
        border-bottom: none; 
        background-color: #f4f9f9; 
    }
    
    /* Los botones de acción se hacen grandes y fáciles de tocar */
    td a, td button, td .btn-accion {
        width: 100% !important;
        display: block !important;
        margin: 8px 0 !important;
        padding: 12px !important;
        box-sizing: border-box;
        font-size: 15px !important;
    }

    /* Adaptación del Login y Ventas */
    .login-wrapper { flex-direction: column; }
    .login-info { padding: 30px 20px; text-align: center; align-items: center; border-right: none; border-bottom: 5px solid #3498db; }
    .login-info ul li { text-align: left; }
    .login-form-box { padding: 30px 20px; }
    .header-perfil { flex-direction: column; gap: 10px; text-align: center; }
    .cliente-info { flex-direction: column; text-align: center; gap: 10px;}
    .radio-group { flex-direction: column; gap: 10px; }
}