@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;1,400;1,600&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap');

:root {
    --primary-color: #6b9e70;
    --primary-dark: #3a6b3e;
    --primary-light: #edf4ee;
    --accent-color: #c9a84c;
    --accent-light: #fdf6e3;
    --bg-color: #f5f0e8;
    --surface-color: #fffef9;
    --text-color: #1e2a1c;
    --text-muted: #7a876f;
    --alert-color: #c85a3a;
    --border: #e2ddd3;
    --gold: #c9a84c;
    --gold-light: #f0e6c8;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 12px rgba(30,42,28,0.06);
    --shadow: 0 6px 24px rgba(30,42,28,0.10);
    --shadow-lg: 0 16px 48px rgba(30,42,28,0.16);
    --sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

h1, h2 {
    font-family: 'Playfair Display', serif;
    letter-spacing: -0.01em;
}
h3 { font-family: 'Inter', sans-serif; font-weight: 600; }
h1 { font-size: 1.7rem; font-weight: 600; color: var(--primary-dark); }

/* ── LAYOUT ── */
.app-container { display: grid; grid-template-columns: var(--sidebar-width) 1fr; height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
    background:
        radial-gradient(ellipse at 20% 20%, rgba(201,168,76,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 80%, rgba(107,158,112,0.12) 0%, transparent 60%),
        linear-gradient(180deg, #0d1a0e 0%, #152818 40%, #1e3520 100%);
    padding: 2rem 1.2rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow: hidden;
    position: relative;
}

.sidebar::before {
    content: '✦  ·  ✦  ·  ✦';
    position: absolute;
    top: 10px;
    left: 0; right: 0;
    text-align: center;
    font-size: 0.5rem;
    color: rgba(201,168,76,0.25);
    letter-spacing: 6px;
}

.sidebar::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 160px;
    background: radial-gradient(ellipse at 50% 100%, rgba(201,168,76,0.06) 0%, transparent 70%);
    pointer-events: none;
}

.logo {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(201,168,76,0.2);
    padding-bottom: 1.2rem;
}
.logo-alba {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 1.6rem;
    font-weight: 400;
    color: #f0ece4;
    display: block;
    line-height: 1.1;
}
.logo-parrado {
    font-family: 'Inter', sans-serif;
    font-style: normal;
    font-weight: 300;
    font-size: 0.68rem;
    display: block;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    opacity: 0.85;
    margin-top: 4px;
}

.main-nav { display: flex; flex-direction: column; gap: 3px; }

.nav-btn {
    background: none;
    border: none;
    padding: 0.72rem 1rem;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    color: rgba(240,236,228,0.55);
    font-size: 0.86rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    display: flex;
    gap: 10px;
    align-items: center;
}
.nav-btn:hover {
    background: rgba(201,168,76,0.08);
    color: rgba(240,236,228,0.9);
}
.nav-btn.active {
    background: rgba(201,168,76,0.12);
    color: #f0ece4;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--gold);
}

/* ── CONTENT ── */
.content-area { padding: 2.2rem 2.8rem; overflow-y: auto; }
.view { display: none; }
.view.active { display: block; }

header { margin-bottom: 1.8rem; }
header p { color: var(--text-muted); font-size: 0.88rem; margin-top: 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* ── CARDS ── */
.stat-card {
    background: var(--surface-color);
    padding: 1.5rem 1.8rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(201,168,76,0.4), transparent);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.stat-number {
    font-family: 'Cormorant Garamond', serif;
    font-size: 3.2rem;
    font-weight: 300;
    color: var(--primary-dark);
    line-height: 1;
    letter-spacing: -0.02em;
}

/* ── BUTTONS ── */
.btn-primary {
    background: linear-gradient(135deg, #5a9060 0%, #3a6b3e 100%);
    color: white;
    border: none;
    padding: 0.68rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.86rem;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(58,107,62,0.35);
    position: relative;
    overflow: hidden;
}
.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(58,107,62,0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-secondary {
    background: var(--surface-color);
    border: 1px solid var(--border);
    padding: 0.62rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.86rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary-color); color: var(--primary-dark); }

.btn-mini {
    background: var(--surface-color);
    border: 1px solid var(--border);
    width: 30px; height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.15s;
}
.btn-mini:hover { background: var(--gold-light); border-color: var(--gold); }

/* ── FORMS ── */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.38rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background: var(--bg-color);
    transition: border-color 0.18s, box-shadow 0.18s;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107,158,112,0.15);
    background: white;
}
input[type="search"] { background: white; }

/* ── CLIENTS ── */
.clients-list { display: grid; gap: 0.7rem; }

.client-card {
    background: var(--surface-color);
    padding: 1.1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    transition: box-shadow 0.2s, transform 0.15s;
    position: relative;
}
.client-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.client-info h3 { font-size: 0.98rem; margin-bottom: 2px; font-family: 'Inter', sans-serif; }
.client-info p { font-size: 0.78rem; color: var(--text-muted); }
.client-info a { color: var(--primary-color); font-weight: 600; text-decoration: none; }

.bono-manager { display: flex; align-items: center; gap: 0.75rem; }
.bono-status {
    background: var(--primary-light);
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--primary-dark);
    border: 1px solid rgba(107,158,112,0.2);
}
.bono-status.low { color: var(--alert-color); background: #fff4f0; border-color: rgba(200,90,58,0.2); }
.bono-status.debt { color: white; background: var(--alert-color); border-color: transparent; }

/* ── CALENDAR ── */
.calendar-nav { display: flex; align-items: center; gap: 12px; }
.calendar-nav h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    font-weight: 400;
    font-style: italic;
    min-width: 150px;
    text-align: center;
    color: var(--primary-dark);
    letter-spacing: 0.02em;
}

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.calendar-day {
    aspect-ratio: 1;
    background: var(--surface-color);
    border-radius: 10px;
    padding: 5px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
}
.calendar-day:hover { border-color: var(--primary-color); background: var(--primary-light); }
.calendar-day.today {
    border: 2px solid var(--gold);
    background: var(--gold-light);
}
.calendar-day.empty { background: transparent; border-color: transparent; cursor: default; }
.day-number { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }

.event-item {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 3px 5px;
    border-radius: 5px;
    font-size: 0.68rem;
    margin-top: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2px;
}
.event-item button { background: none; border: none; color: rgba(255,255,255,0.75); cursor: pointer; font-weight: bold; }

/* ── AGENTS ── */
.agent-card {
    padding: 1rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--surface-color);
    transition: all 0.2s;
}
.agent-card:hover { border-color: var(--gold); color: var(--text-color); background: var(--gold-light); }
.agent-card.selected {
    background: linear-gradient(135deg, var(--gold-light), #fdf8ee);
    border-color: var(--gold);
    color: #6b4a10;
    font-weight: 600;
    box-shadow: 0 3px 10px rgba(201,168,76,0.2);
}

.ai-response { background: var(--surface-color); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-top: 1rem; }
.ai-content-text { padding: 0; }

/* ── MODALS ── */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13,26,14,0.6);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}
.hidden { display: none !important; }

.modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}
.modal-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 400;
    font-style: italic;
    color: var(--primary-dark);
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.sticky-footer {
    position: sticky;
    bottom: -2rem;
    background: var(--surface-color);
    padding: 1rem 0 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
    body { overflow: auto; }

    .app-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        height: 100dvh;
    }

    /* Sidebar oculta por defecto, overlay al abrirse */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        padding-top: 3.5rem;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,0.35); }

    /* Overlay oscuro detrás del sidebar */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 999;
        backdrop-filter: blur(2px);
    }
    .sidebar-overlay.open { display: block; }

    /* Botón hamburguesa */
    #menu-toggle {
        position: fixed;
        top: 12px; left: 14px;
        z-index: 1001;
        background: rgba(13,26,14,0.9);
        border: none;
        color: #f0ece4;
        font-size: 1.2rem;
        width: 40px; height: 40px;
        border-radius: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    .content-area {
        padding: 4.5rem 1.2rem 1.5rem;
        overflow-y: auto;
        height: 100dvh;
    }

    h1 { font-size: 1.35rem; }

    /* Calendar en móvil */
    .calendar-grid { gap: 3px; }
    .calendar-day { border-radius: 6px; padding: 3px; }
    .day-number { font-size: 0.65rem; }
    .event-item { font-size: 0.6rem; padding: 2px 3px; }
    .calendar-nav h2 { font-size: 1rem; min-width: 110px; }

    /* Dashboard grid */
    .dashboard-grid { grid-template-columns: 1fr !important; }

    /* Clients */
    .client-card { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .bono-manager { width: 100%; justify-content: flex-end; }

    /* Agent cards */
    .agent-selection { grid-template-columns: repeat(2, 1fr) !important; }

    /* Stats */
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-number { font-size: 2.2rem; }

    /* Chat flotante */
    #chat-fab { bottom: 16px; right: 16px; width: 50px; height: 50px; }
    #chat-panel { width: calc(100vw - 32px); right: 16px; bottom: 78px; height: 420px; }

    /* Modal */
    .modal { align-items: flex-end; padding: 0; }
    .modal-content { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 90dvh; }
}

/* ── PRINT ── */
@media print {
    .sidebar, .nav-btn, button, .modal, #chat-fab, #chat-panel, #menu-toggle { display: none !important; }
    .view { display: block !important; }
    body { background: white !important; overflow: visible; }
}
