/* ============================================
   CALENDARIOS-MAP — Diseño Profesional v2
   ============================================ */

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

:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --dark: #0f172a;
    --dark2: #1e293b;
    --gray: #64748b;
    --lgray: #94a3b8;
    --light: #f1f5f9;
    --bg: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.1), 0 4px 10px rgba(0,0,0,.06);
    --radius: 14px;
    --radius-sm: 10px;
    --transition: all .18s ease;
    --sidebar-w: 260px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--dark2);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   APP SHELL
   ============================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ====== SIDEBAR ====== */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #0f1628;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 1045;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    font-weight: 800;
    font-size: 1.05rem;
    color: #fff;
    padding: 14px 12px;
    letter-spacing: -.3px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    text-decoration: none;
    flex-shrink: 0;
    background: #000;
}
.sidebar-map-logo {
    width: auto;
    max-width: 120px;
    max-height: 32px;
    object-fit: contain;
    display: block;
}
.sidebar-brand:hover { color: #fff; }
.sidebar-brand .logo {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 10px;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(79,70,229,.45);
    flex-shrink: 0;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px 20px; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.nav-section {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    color: #475569;
    padding: 16px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #94a3b8;
    font-weight: 500;
    font-size: .84rem;
    text-decoration: none;
    transition: all .15s ease;
    cursor: pointer;
    user-select: none;
    margin-bottom: 1px;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #e2e8f0; }
.nav-link.active {
    background: linear-gradient(135deg, rgba(79,70,229,.8), rgba(124,58,237,.8));
    color: #fff;
    box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.nav-link .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-link .nav-caret { margin-left: auto; font-size: .6rem; transition: transform .2s ease; opacity: .5; }
.nav-group.open > .nav-link .nav-caret { transform: rotate(90deg); }
.nav-link .nav-pill {
    margin-left: auto;
    font-size: .6rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.nav-sub {
    list-style: none;
    margin: 2px 0 4px;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
}
.nav-group.open .nav-sub { max-height: 440px; }
.nav-sub a {
    display: block;
    padding: 7px 12px 7px 44px;
    color: #64748b;
    font-size: .78rem;
    text-decoration: none;
    border-radius: 8px;
    transition: all .15s ease;
    position: relative;
    margin-bottom: 1px;
}
.nav-sub a::before {
    content: '';
    position: absolute;
    left: 24px; top: 50%;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #334155;
    transform: translateY(-50%);
    transition: background .15s ease;
}
.nav-sub a:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-sub a:hover::before, .nav-sub a.active::before { background: #818cf8; }
.nav-sub a.active { color: #c7d2fe; font-weight: 600; }

.sidebar-foot {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sidebar-foot .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: .8rem;
    flex-shrink: 0;
}
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who .name { color: #e2e8f0; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who .role { color: #475569; font-size: .65rem; text-transform: uppercase; letter-spacing: .5px; }
.sidebar-foot .logout {
    color: #64748b;
    background: rgba(255,255,255,.06);
    border: none;
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    text-decoration: none;
    transition: all .15s ease;
    flex-shrink: 0;
    font-size: 1rem;
}
.sidebar-foot .logout:hover { background: var(--danger); color: #fff; }

/* ====== MAIN ====== */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    min-height: 60px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow);
}
.topbar .page-title { font-size: 1.05rem; font-weight: 700; color: var(--dark); margin: 0; letter-spacing: -.2px; }
.topbar .page-sub { font-size: .73rem; color: var(--gray); margin: 0; }
.topbar .topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.topbar-user {
    display: flex; flex-direction: column; align-items: flex-end;
    text-decoration: none; color: var(--dark2);
    background: var(--light); border: 1px solid var(--border);
    border-radius: 12px; padding: 5px 14px;
    transition: var(--transition); line-height: 1.3;
}
.topbar-user:hover { background: #e0e7ff; border-color: var(--primary); color: var(--primary); }
.topbar-name { display: block; font-size: .78rem; font-weight: 600; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.topbar-role { display: block; font-size: .62rem; font-weight: 500; color: #111; white-space: nowrap; }
.topbar-user:hover .topbar-role { color: var(--primary); }

.menu-toggle {
    display: none;
    background: var(--light);
    border: none;
    width: 38px; height: 38px;
    border-radius: 10px;
    font-size: 1.1rem;
    color: var(--dark);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.menu-toggle:hover { background: var(--border); }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .74rem;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 999px;
    text-decoration: none;
    transition: var(--transition);
}
.status-pill.on { background: #dcfce7; color: #166534; }
.status-pill.off { background: #fee2e2; color: #991b1b; }
.status-pill.off:hover { background: var(--danger); color: #fff; }

.content { padding: 20px; flex: 1; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 1044;
    backdrop-filter: blur(3px);
}
.sidebar-backdrop.show { display: block; }

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    padding: 14px 18px;
    font-size: .9rem;
}
.card-body { padding: 18px; }

/* Module cards on dashboard */
.module-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    height: 100%;
    transition: var(--transition);
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    display: block;
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: inherit; border-color: transparent; }
.module-card .m-icon {
    width: 50px; height: 50px;
    border-radius: 13px;
    display: grid; place-items: center;
    font-size: 1.4rem;
    margin-bottom: 14px;
}
.module-card h6 { font-weight: 700; margin: 0 0 3px; font-size: .9rem; }
.module-card .m-sub { color: var(--gray); font-size: .8rem; margin: 0; }
.module-card .m-value { font-size: 1.5rem; font-weight: 800; color: var(--dark); }

/* ============================================
   NAVBAR (landing)
   ============================================ */
.navbar {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
    box-shadow: var(--shadow-md);
    padding: 10px 0;
}
.navbar-brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -.4px; }
.navbar .btn { font-weight: 600; font-size: .82rem; padding: 7px 16px; transition: var(--transition); }
.navbar .btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

/* ============================================
   CALENDAR SIDEBAR
   ============================================ */
.cal-box {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    margin-bottom: 7px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 4px solid;
    font-size: .83rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    line-height: 1.3;
}
.cal-box:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.cal-box .cal-email { font-weight: 400; color: var(--gray); font-size: .7rem; display: block; margin-top: 1px; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 600;
    border-radius: 20px;
    padding: 8px 18px;
    transition: var(--transition);
    font-size: .84rem;
    line-height: 1.4;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #000; }
.btn-danger { background: var(--danger); border-color: var(--danger); }

.btn-go {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border-radius: 25px;
    font-weight: 700;
    padding: 10px 20px;
    border: none;
    width: 100%;
    font-size: .84rem;
    box-shadow: 0 4px 14px rgba(79,70,229,.35);
    transition: var(--transition);
    cursor: pointer;
}
.btn-go:hover { box-shadow: 0 6px 20px rgba(79,70,229,.5); transform: translateY(-2px); }
.btn-go:active { transform: translateY(0); }

/* ============================================
   PENDING ITEMS
   ============================================ */
.pend-item {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 7px;
    border-left: 3px solid var(--warning);
    font-size: .8rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.pend-item strong { font-size: .82rem; color: var(--dark); }
.pend-item:hover { box-shadow: var(--shadow-md); }

/* ============================================
   FORMS
   ============================================ */
.form-label {
    font-size: .7rem;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 4px;
    display: block;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    font-size: .85rem;
    padding: 9px 13px;
    transition: var(--transition);
    background: var(--white);
    color: var(--dark2);
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    outline: none;
}
.not-upper { text-transform: none !important; }
textarea.form-control { resize: vertical; min-height: 70px; }

/* ============================================
   MODAL
   ============================================ */
.modal-content { border-radius: var(--radius); border: none; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 14px 20px;
    border-bottom: none;
}
.modal-header .btn-close { filter: brightness(0) invert(1); }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 20px; gap: 8px; }

/* ============================================
   AUTOCOMPLETE
   ============================================ */
.sug-box {
    position: absolute;
    left: 0; right: 0; top: 100%;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 180px;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
    z-index: 9999;
    display: none;
}
.sug-item {
    padding: 8px 13px;
    cursor: pointer;
    font-size: .83rem;
    transition: background .12s;
}
.sug-item:hover { background: #eef2ff; }
.sug-new { color: var(--primary); font-weight: 600; }

/* ============================================
   NOTIFY ROWS
   ============================================ */
.notify-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }

/* ============================================
   SECTION LABELS
   ============================================ */
.section-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 14px 0 8px;
    display: block;
}

/* ============================================
   FULLCALENDAR
   ============================================ */
.fc { font-family: 'Inter', sans-serif; }
.fc-toolbar-title { font-weight: 800 !important; font-size: 1rem !important; }
.fc-button {
    border-radius: 18px !important;
    font-weight: 600 !important;
    font-size: .78rem !important;
    padding: 5px 13px !important;
    transition: all .15s !important;
}
.fc-button-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.fc-button-primary:hover { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }
.fc-button-primary:not(.fc-button-active):not(.fc-prev-button):not(.fc-next-button):hover { transform: translateY(-1px); }
.fc-event {
    border-radius: 6px !important;
    font-size: .72rem !important;
    font-weight: 600 !important;
    padding: 2px 5px !important;
    border: none !important;
    cursor: pointer;
}
.fc-daygrid-event { border-radius: 5px !important; }
.fc-event:hover { filter: brightness(1.1); }

/* ============================================
   FOOTER
   ============================================ */
.f-credit {
    text-align: center;
    padding: 14px;
    font-size: .73rem;
    color: var(--lgray);
    background: var(--white);
    border-top: 1px solid var(--border);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.card, .cal-box, .pend-item, .module-card { animation: fadeIn .25s ease; }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   UTILITIES
   ============================================ */
.dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 5px;
    vertical-align: middle;
}
.section-title {
    font-weight: 700;
    font-size: .92rem;
    color: var(--dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    scroll-margin-top: 80px;
}
.section-heading { scroll-margin-top: 80px; }
.edit-input {
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: .8rem;
    width: 100%;
    transition: var(--transition);
}
.edit-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.1);
    outline: none;
}
.badge-pendiente {
    display: inline-block;
    font-size: .66rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
}
.cal-check {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}
.cal-check:hover { border-color: var(--primary); background: #f8faff; }
.cal-check.selected { border-color: var(--primary); background: #eef2ff; }
.cal-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

.table-sm th {
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray);
    border-bottom: 2px solid var(--border);
    font-weight: 700;
}

/* Alert improvements */
.alert { border-radius: var(--radius-sm); border: none; font-size: .85rem; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }

/* ============================================
   RESPONSIVE — Tablet
   ============================================ */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .content { padding: 16px; }
}

/* ============================================
   RESPONSIVE — Mobile
   ============================================ */
@media (max-width: 768px) {
    :root { --sidebar-w: 270px; }

    .modal-dialog { margin: 8px; }
    .modal-body { max-height: 60vh; padding: 16px; }
    .modal-header { padding: 12px 16px; }

    .topbar { padding: 8px 14px; min-height: 54px; }
    .topbar .page-title { font-size: .95rem; }
    .content { padding: 12px; }

    .cal-box { font-size: .8rem; }
    .btn-go { padding: 12px 16px; }

    /* FullCalendar mobile */
    .fc-toolbar-title { font-size: .85rem !important; }
    .fc-button { font-size: .7rem !important; padding: 4px 9px !important; }
    .fc-header-toolbar { gap: 4px !important; }
    .fc-event { font-size: .65rem !important; }

    /* Stack rows on mobile */
    .row.mb-3 > [class*="col-md"] { margin-bottom: 12px; }
    .row.mb-2 > [class*="col-md"] { margin-bottom: 10px; }

    /* Module cards */
    .module-card { padding: 16px; }
    .module-card .m-icon { width: 42px; height: 42px; font-size: 1.2rem; margin-bottom: 10px; }

    /* Pend actions */
    .pend-actions .btn { padding: 4px 12px; }

    /* Day picker mobile */
    .day-btn { width: 34px; height: 34px; font-size: .75rem; }
}

@media (max-width: 480px) {
    .topbar-actions .status-pill { display: none; }
    .topbar-name { max-width: 110px; font-size: .72rem; }
    .fc-right { display: none !important; }
    .modal-footer { flex-wrap: wrap; gap: 6px; }
    .modal-footer .btn { flex: 1; min-width: 80px; text-align: center; }
}
