/* css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* PALETA CORPORATIVA - MODO CLARO (DEFAULT) */
    --corp-dark: #0f172a;
    /* Azul noche profundo */
    --corp-light: #2563eb;
    /* Azul vibrante moderno */
    --corp-light-hover: #1d4ed8;

    /* COLORES UI */
    --bg-body: #f1f5f9;
    /* Slate 100 */
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    /* Slate 900 */
    --bg-header: #ffffff;

    --text-main: #1e293b;
    /* Slate 800 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-on-dark: #f8fafc;

    --border-color: #e2e8f0;
    /* Slate 200 */
    --input-bg: #f8fafc;

    /* ESTADOS */
    --success-bg: #dcfce7;
    --success-text: #15803d;
    --danger-bg: #fee2e2;
    --danger-text: #b91c1c;
    --warning-bg: #fef9c3;
    --warning-text: #a16207;

    /* SOMBRAS */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 15px rgba(37, 99, 235, 0.15);
}

/* --- DARK MODE --- */
[data-theme="dark"] {
    --bg-body: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    /* Slate 800 */
    --bg-sidebar: #020617;
    /* Slate 950 */
    --bg-header: #1e293b;

    --text-main: #f1f5f9;
    /* Slate 100 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --border-color: #334155;
    /* Slate 700 */
    --input-bg: #0f172a;

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);

    /* Ajustes de contraste para estados */
    --success-bg: rgba(22, 163, 74, 0.2);
    --success-text: #4ade80;
    --danger-bg: rgba(220, 38, 38, 0.2);
    --danger-text: #f87171;
    --warning-bg: rgba(234, 179, 8, 0.2);
    --warning-text: #facc15;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    z-index: 10;
    transition: background-color 0.3s ease;
}

.sidebar .brand {
    font-size: 1.5rem;
    font-weight: 800;
    padding: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
}

.sidebar .brand span {
    color: var(--corp-light);
}

.sidebar .menu {
    padding: 20px 15px;
    flex: 1;
    overflow-y: auto;
}

.sidebar a {
    color: #94a3b8;
    text-decoration: none;
    padding: 12px 16px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sidebar a i {
    width: 24px;
    text-align: center;
    margin-right: 10px;
    font-size: 1.1em;
}

.sidebar a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    transform: translateX(4px);
}

.sidebar a.active {
    background: var(--corp-light);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.menu-label {
    margin: 25px 15px 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 700;
    letter-spacing: 1px;
}

/* --- USER PANEL (SIDEBAR FOOTER) --- */
.user-panel {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.1);
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--corp-light);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.user-role {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* --- MAIN WRAPPER --- */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* --- TOP HEADER --- */
.top-header {
    height: 70px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space between title/context and actions */
    padding: 0 30px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Theme Toggle Button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    /* Circle */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1.1rem;
}

.theme-toggle:hover {
    background: var(--bg-body);
    color: var(--corp-light);
    border-color: var(--corp-light);
}

.btn-logout {
    color: var(--danger-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    transition: 0.2s;
    background: var(--danger-bg);
}

.btn-logout:hover {
    opacity: 0.8;
}


/* --- CONTENT AREA --- */
.content-area {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

h2,
h3 {
    font-weight: 700;
    color: var(--text-main);
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    letter-spacing: -1px;
}

/* --- CARD GENERIC --- */
.card,
.box {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.box-title {
    margin: 0 0 20px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

/* --- FORMS & BUTTONS --- */
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--corp-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    background: var(--corp-light);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.2);
}

.btn:hover {
    background: var(--corp-light-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

/* --- DATATABLES & LISTS --- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-body);
}

table th:first-child {
    border-top-left-radius: 8px;
}

table th:last-child {
    border-top-right-radius: 8px;
}

table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 0.9rem;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}


/* --- DASHBOARD SPECIFIC (Merged from embedded) --- */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 30px;
}

/* Currency Switch */
.currency-switch {
    display: flex;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.curr-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: 0.2s;
    text-decoration: none;
    display: block;
    font-size: 0.85rem;
}

.curr-btn:hover {
    background: var(--bg-body);
}

.curr-btn.active {
    background: var(--corp-dark);
    color: white;
}

.curr-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-right: 15px;
    font-weight: 600;
    align-self: center;
}

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}

.kpi-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
}

/* Decorativo lateral */
.kpi-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--corp-light);
}

.kpi-card.green::before {
    background: #16a34a;
}

.kpi-card.purple::before {
    background: #9333ea;
}

.kpi-val {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 5px;
    letter-spacing: -0.5px;
}

.kpi-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.kpi-icon {
    font-size: 2.5rem;
    opacity: 0.1;
    color: var(--text-main);
}


/* CHARTS GRID */
.grid-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .grid-charts {
        grid-template-columns: 1fr;
    }
}

/* RENEWALS LIST */
.renew-item {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.renew-item:last-child {
    border-bottom: none;
}

.renew-date {
    font-size: 0.75rem;
    background: var(--warning-bg);
    color: var(--warning-text);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
}

.company-link {
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    display: block;
    font-size: 0.95rem;
}

.company-link:hover {
    color: var(--corp-light);
}

.deal-name {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.amount-text {
    font-weight: 700;
    color: var(--success-text);
    font-size: 0.95rem;
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* --- MOBILE & TABLET OPTIMIZATIONS (App-Like Feel) --- */
@media (max-width: 768px) {

    /* 1. LAYOUT GENERAL */
    body {
        flex-direction: column;
        height: 100dvh;
        /* Dynamic viewport height for mobiles */
        overflow: hidden;
        /* Control scroll manually in content */
    }

    /* 2. SIDEBAR -> BOTTOM NAVIGATION */
    .sidebar {
        width: 100%;
        height: 70px;
        /* Altura barra inferior */
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 1000;
        padding: 0;
        background: var(--bg-card);
        /* Mejor contraste en fondo */
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
        overflow: hidden;
    }

    /* Hide Desktop Elements */
    .sidebar .brand,
    .sidebar .user-panel,
    .menu-label {
        display: none !important;
    }

    /* Transform Menu Links */
    .sidebar .menu {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        /* Scroll horizontal si hay muchos iconos */
        padding: 0 10px;
        gap: 5px;
        align-items: center;
        justify-content: flex-start;
        /* Permite scroll */
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox hide scrollbar */
    }

    .sidebar .menu::-webkit-scrollbar {
        display: none;
        /* Chrome hide scrollbar */
    }

    .sidebar a {
        flex-direction: column;
        justify-content: center;
        padding: 8px 5px;
        margin: 0;
        min-width: 65px;
        /* Touch target size */
        font-size: 0.65rem;
        background: transparent !important;
        /* Remove hover bg default */
        color: var(--text-muted);
        border-radius: 8px;
        text-align: center;
        white-space: nowrap;
    }

    .sidebar a i {
        margin: 0 0 4px 0;
        font-size: 1.3rem;
        display: block;
        width: 100%;
    }

    .sidebar a.active {
        color: var(--corp-light);
        background: transparent;
        position: relative;
    }

    /* Indicador activo estilo app */
    .sidebar a.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 3px;
        background: var(--corp-light);
        border-radius: 0 0 4px 4px;
        display: none;
        /* Opcional: quitar display none si se quiere la barra superior */
    }

    /* 3. MAIN WRAPPER & CONTENT */
    .main-wrapper {
        width: 100%;
        height: calc(100% - 70px);
        /* Restar barra inferior */
        overflow: hidden;
    }

    .content-area {
        padding: 15px;
        /* Menor padding */
        padding-bottom: 30px;
        /* Espacio extra al final */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 4. TOP HEADER */
    .top-header {
        padding: 0 15px;
        height: 60px;
        z-index: 50;
    }

    /* Mostrar logo/marca en header movil si está vacío el breadcrumb */
    .top-header>div:first-child:empty::before {
        content: 'GLOBETEC';
        font-weight: 800;
        color: var(--corp-light);
        font-size: 1.2rem;
    }

    /* 5. TABLES & GRIDS */
    /* Hacer tablas scrollables horizontalmente */
    .card,
    .box {
        padding: 15px;
        overflow-x: auto;
    }

    table {
        min-width: 600px;
        /* Forzar ancho mínimo para activar scroll */
    }

    .grid-container,
    .grid-charts,
    .kpi-grid {
        grid-template-columns: 1fr !important;
        /* Stack todo en 1 columna */
        gap: 15px;
    }

    /* 6. MODALS */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: 100%;
        /* Pantalla completa en movil */
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    .modal-body {
        flex: 1;
    }

    /* Form Grid a 1 columna */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    /* 7. KANBAN (Board) */
    .kanban-container {
        flex-direction: column;
        /* Stack columns on mobile? Or scroll horizontal? */
        /* Mejor scroll horizontal para App feel pero en movil puede ser confuso. 
           Vamos a probar scroll snap horizontal */
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 10px;
    }

    .kanban-col {
        min-width: 85vw;
        /* Casi ancho completo */
        scroll-snap-align: center;
    }

    /* Ajustes generales UI App */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    /* Filtros en una columna */
    .filter-bar {
        flex-wrap: wrap;
    }

    .filter-group {
        flex: 1 1 45%;
        /* 2 por fila */
    }

    /* Botones mas grandes para touch */
    .btn,
    button,
    input,
    select {
        min-height: 44px;
    }
}