/* ===== Font ===== */
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* ===== NProgress Override ===== */
#nprogress .bar {
    background: var(--primary-500, #10b981) !important;
    height: 3px !important;
}
#nprogress .peg {
    box-shadow: 0 0 10px var(--primary-500, #10b981), 0 0 5px var(--primary-500, #10b981) !important;
}
#nprogress .spinner-icon {
    border-top-color: var(--primary-500, #10b981) !important;
    border-left-color: var(--primary-500, #10b981) !important;
}

/* ===== Glass Header ===== */
.glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ===== Nav Items (sidebar) ===== */
.nav-item { position: relative; }
.nav-item::before {
    content: ''; position: absolute; left: 0; top: 50%;
    transform: translateY(-50%) scaleY(0); width: 4px; height: 60%;
    background: white; border-radius: 0 4px 4px 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}
.nav-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
    font-weight: 600;
}
.nav-item.active::before {
    transform: translateY(-50%) scaleY(1);
}

/* Sub-link active */
.sub-link-active {
    background: rgba(255,255,255,0.15) !important;
    color: white !important;
    font-weight: 600 !important;
}

/* ===== Sidebar Scrollbar ===== */
#sidebar nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.1) transparent; }
#sidebar nav::-webkit-scrollbar { width: 4px; }
#sidebar nav::-webkit-scrollbar-track { background: transparent; }
#sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 20px; }
#sidebar nav:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); }

/* ===== Mobile sidebar overlay ===== */
@media (min-width: 1024px) {
    #sidebar-overlay { display: none !important; }
}

/* ===== Login Bubbles ===== */
.bubble {
    position: absolute;
    bottom: -100px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    animation: bubbleFloat linear infinite;
}
.bubble:nth-child(1)  { width: 40px; height: 40px; left: 10%; animation-duration: 8s; animation-delay: 0s; }
.bubble:nth-child(2)  { width: 20px; height: 20px; left: 20%; animation-duration: 12s; animation-delay: 1s; }
.bubble:nth-child(3)  { width: 50px; height: 50px; left: 35%; animation-duration: 7s; animation-delay: 2s; }
.bubble:nth-child(4)  { width: 80px; height: 80px; left: 50%; animation-duration: 11s; animation-delay: 0s; }
.bubble:nth-child(5)  { width: 35px; height: 35px; left: 55%; animation-duration: 6s; animation-delay: 1s; }
.bubble:nth-child(6)  { width: 45px; height: 45px; left: 65%; animation-duration: 8s; animation-delay: 3s; }
.bubble:nth-child(7)  { width: 25px; height: 25px; left: 70%; animation-duration: 13s; animation-delay: 2s; }
.bubble:nth-child(8)  { width: 60px; height: 60px; left: 80%; animation-duration: 7s; animation-delay: 0s; }
.bubble:nth-child(9)  { width: 15px; height: 15px; left: 90%; animation-duration: 9s; animation-delay: 1s; }
.bubble:nth-child(10) { width: 70px; height: 70px; left: 25%; animation-duration: 10s; animation-delay: 4s; }
.bubble:nth-child(11) { width: 30px; height: 30px; left: 40%; animation-duration: 8s; animation-delay: 2s; }
.bubble:nth-child(12) { width: 55px; height: 55px; left: 60%; animation-duration: 9s; animation-delay: 0s; }
.bubble:nth-child(13) { width: 18px; height: 18px; left: 75%; animation-duration: 11s; animation-delay: 3s; }
.bubble:nth-child(14) { width: 42px; height: 42px; left: 5%;  animation-duration: 7s; animation-delay: 1s; }
.bubble:nth-child(15) { width: 28px; height: 28px; left: 85%; animation-duration: 12s; animation-delay: 2s; }

@keyframes bubbleFloat {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { transform: translateY(-110vh) rotate(720deg); opacity: 0; }
}

/* ===== Page Transition ===== */
.page-enter { animation: pageEnter 0.35s ease-out forwards; }
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Main Scrollbar ===== */
#main-content { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
#main-content::-webkit-scrollbar { width: 6px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
#main-content::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== Card Hover ===== */
.card-hover { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: 0 8px 25px -5px rgba(0,0,0,0.08); }

/* ===== Modern Select ===== */
select.modern-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
select.modern-select:hover {
    border-color: #a5b4fc;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
}
select.modern-select:focus {
    border-color: var(--primary-500, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select.modern-select option {
    padding: 10px 14px;
    background: #fff;
    color: #1f2937;
}
select.modern-select option:checked {
    background: linear-gradient(0deg, rgba(99,102,241,0.12) 0%, rgba(99,102,241,0.12) 100%);
    font-weight: 600;
}

/* ===== Mobile Card Table ===== */
@media (max-width: 639px) {
    .table-responsive thead { display: none; }
    .table-responsive tbody tr {
        display: block;
        margin-bottom: 12px;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        padding: 12px;
        background: white;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
    }
    .table-responsive tbody td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 6px 0 !important;
        border: none !important;
        text-align: right;
    }
    .table-responsive tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        text-align: left;
        margin-right: 12px;
        flex-shrink: 0;
    }
    .table-responsive tbody td:last-child {
        justify-content: flex-end;
        padding-top: 8px !important;
        border-top: 1px solid #f3f4f6 !important;
        margin-top: 4px;
    }
    .table-responsive .divide-y > * + * { border-top: none; }
}

/* ===== Mobile Card Shadows for Contrast ===== */
@media (max-width: 639px) {
    #page-content .bg-white {
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    }
}

/* ===== Responsive Buttons ===== */
@media (max-width: 639px) {
    .btn-group-responsive { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
    .btn-group-responsive > * { flex: 1 1 auto; text-align: center; justify-content: center; }
}

/* ===== Modern Dropdown (custom replacement for native .modern-select) ===== */
/* The original <select> is hidden but kept in the DOM for form submission. */
form input[type="date"] {
    min-height: 38px;
    line-height: 1.25rem;
}

/* Native <select> is fully hidden once wrapped — form submit still includes its value. */
select.modern-dd__native {
    display: none !important;
}

.modern-dd {
    position: relative;
    display: block;
    width: 100%;
}
.modern-dd__btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    min-height: 38px;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #1f2937;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.modern-dd__btn:hover {
    border-color: #a5b4fc;
}
.modern-dd__btn:focus-visible,
.modern-dd.is-open .modern-dd__btn {
    outline: none;
    border-color: var(--primary-500, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.modern-dd__label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.modern-dd__label.is-placeholder {
    color: #9ca3af;
}
.modern-dd__chev {
    font-size: 0.75rem;
    color: #6b7280;
    transition: transform .2s ease;
    flex: 0 0 auto;
}
.modern-dd.is-open .modern-dd__chev {
    transform: rotate(180deg);
    color: var(--primary-600, #4f46e5);
}

/* Portaled panel (appended to <body>, position:fixed). */
.modern-dd__panel {
    position: fixed;
    z-index: 9999;
    min-width: 12rem;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
    padding: 4px;
    animation: modernDdIn .12s ease-out;
}
.modern-dd__panel[hidden] { display: none; }

@keyframes modernDdIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modern-dd__opt {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #1f2937;
    cursor: pointer;
    user-select: none;
    transition: background-color .1s ease, color .1s ease;
}
.modern-dd__opt:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-700, #4338ca);
}
.modern-dd__opt.is-selected {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-700, #4338ca);
    font-weight: 600;
}
