/* ============================================================
   e-Counseling - BK Madrasah Matholi'ul Huda
   Modern Minimalist Green Theme
   ============================================================ */

:root {
    --primary: #166534;
    --primary-dark: #14532d;
    --primary-light: #22c55e;
    --primary-lighter: #4ade80;
    --primary-soft: #86efac;
    --primary-bg: #f0fdf4;
    --sidebar-width: 250px;
    --topbar-height: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--primary-bg);
    color: #1f2937;
    overflow-x: hidden;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: linear-gradient(135deg, var(--primary-dark), var(--primary)) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1040;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    z-index: 1050;
    overflow-y: auto;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    min-height: var(--topbar-height);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h6 {
    color: #fff;
    font-size: 0.95rem;
}

.sidebar-menu {
    flex: 1;
    padding: 0.5rem 0;
}

.sidebar-menu .nav-link {
    color: rgba(255,255,255,0.75);
    padding: 0.7rem 1.2rem;
    font-size: 0.88rem;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-menu .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--primary-lighter);
}

.sidebar-menu .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--primary-lighter);
    font-weight: 500;
}

.sidebar-menu .nav-section span {
    display: block;
    padding: 0.8rem 1.2rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}

/* --- Sidebar Dropdown --- */
.sidebar-dropdown > .nav-link {
    cursor: pointer;
    user-select: none;
}

.sidebar-dropdown > .nav-link .dropdown-icon {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.25s ease;
}

.sidebar-dropdown.open > .nav-link .dropdown-icon {
    transform: rotate(180deg);
}

.sidebar-dropdown .sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-dropdown.open .sidebar-submenu {
    max-height: 300px;
}

.sidebar-dropdown .sidebar-submenu .nav-link {
    padding: 0.5rem 1.2rem 0.5rem 2.8rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.6);
    border-left: 3px solid transparent;
}

.sidebar-dropdown .sidebar-submenu .nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: var(--primary-lighter);
}

.sidebar-dropdown .sidebar-submenu .nav-link.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: var(--primary-lighter);
    font-weight: 500;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.8rem;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1045;
}

.sidebar-overlay.show {
    display: block;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 1.5rem;
    min-height: calc(100vh - var(--topbar-height) - 50px);
    transition: margin-left 0.3s ease;
}

.ta-info {
    background: #fff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border-left: 3px solid var(--primary);
}

/* --- Cards --- */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* --- Stat Cards --- */
.stat-card {
    border-radius: 12px;
    padding: 1.25rem;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    font-size: 3rem;
    opacity: 0.25;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.bg-stat-green { background: linear-gradient(135deg, #166534, #22c55e); }
.bg-stat-blue  { background: linear-gradient(135deg, #1e40af, #3b82f6); }
.bg-stat-amber { background: linear-gradient(135deg, #92400e, #f59e0b); }
.bg-stat-rose  { background: linear-gradient(135deg, #9f1239, #f43f5e); }
.bg-stat-teal  { background: linear-gradient(135deg, #115e59, #14b8a6); }
.bg-stat-purple{ background: linear-gradient(135deg, #581c87, #a855f7); }

/* --- Tables --- */
.table-responsive {
    border-radius: 8px;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

/* --- Buttons --- */
.btn {
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.45rem 1rem;
    transition: all 0.2s;
}

.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(--primary-light);
    border-color: var(--primary-light);
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

/* --- Forms --- */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #d1d5db;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #374151;
    margin-bottom: 0.3rem;
}

/* --- Footer --- */
.footer {
    margin-left: var(--sidebar-width);
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 0.8rem 1.5rem;
    transition: margin-left 0.3s ease;
}

/* --- Alert --- */
.alert {
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
}

.alert i {
    margin-right: 6px;
}

/* --- Badge --- */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* --- Modal --- */
.modal-content {
    border: none;
    border-radius: 12px;
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

/* --- Pagination --- */
.pagination .page-link {
    border: none;
    border-radius: 8px !important;
    margin: 0 2px;
    color: var(--primary);
    font-weight: 500;
}

.pagination .page-item.active .page-link {
    background: var(--primary);
    color: #fff;
}

/* --- Sidebar collapsed (desktop) --- */
.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-collapsed .main-content,
.sidebar-collapsed .footer {
    margin-left: 0;
}

/* --- Login Page --- */
.login-page {
    background: #fff;
}

.login-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Hero Panel (Left) ── */
.login-hero {
    flex: 1;
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 100vh;
    padding: 60px;
    overflow: hidden;
}

.login-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: url('../images/hero-login.jpg');
    background-size: cover;
    background-position: center;
}

.login-hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        135deg,
        rgba(20, 83, 45, 0.62) 0%,
        rgba(22, 101, 52, 0.42) 50%,
        rgba(21, 128, 61, 0.55) 100%
    );
}

.login-hero-pattern {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0.06;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 30px,
        rgba(255,255,255,0.05) 30px,
        rgba(255,255,255,0.05) 60px
    );
}

.login-hero-content {
    position: relative;
    z-index: 3;
    color: #fff;
    max-width: 480px;
    animation: fadeInUp 800ms ease-out;
}

.login-hero-content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 12px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.login-hero-content p {
    font-size: 1rem;
    opacity: 0.85;
    line-height: 1.7;
}

.hero-features {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.hero-feature-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.hero-feature-tag i {
    color: var(--primary-lighter);
}

/* ── Form Panel (Right) ── */
.login-form-wrapper {
    width: 520px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: #fff;
}

.login-form-inner {
    width: 100%;
    max-width: 380px;
    animation: fadeIn 600ms ease-out 200ms both;
}

.login-logo-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.login-logo-row img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.login-logo-row h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    line-height: 1.3;
}

.login-logo-row small {
    font-size: 0.72rem;
    color: #6b7280;
    font-weight: 500;
}

.login-greeting {
    margin: 24px 0;
}

.login-greeting h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.login-greeting p {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0;
}

/* ── Floating Inputs ── */
.login-form .form-floating {
    margin-bottom: 16px;
}

.login-form .form-floating .form-control {
    height: 50px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    padding-left: 44px;
    background: #fff;
}

.login-form .form-floating .form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px rgba(22,101,52,0.1);
}

.login-form .form-floating > label {
    padding-left: 44px;
    font-size: 0.85rem;
    color: #6b7280;
}

.login-form .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1rem;
    z-index: 5;
    pointer-events: none;
    transition: color 0.2s ease;
}

.login-form .form-floating:focus-within .input-icon {
    color: var(--primary);
}

.login-form .password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    color: #9ca3af;
    cursor: pointer;
    z-index: 5;
    font-size: 1rem;
    transition: color 0.2s ease;
}

.login-form .password-toggle:hover {
    color: var(--primary);
}

/* ── Submit Button ── */
.login-btn {
    width: 100%;
    height: 50px;
    margin-top: 6px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.login-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(22,101,52,0.35);
    color: #fff;
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn .spinner-border {
    width: 20px;
    height: 20px;
    display: none;
}

.login-btn.loading .btn-text {
    visibility: hidden;
}

.login-btn.loading .spinner-border {
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Footer ── */
.login-footer {
    margin-top: 32px;
    text-align: center;
    font-size: 0.75rem;
    color: #6b7280;
}

.login-footer p {
    margin: 0;
    line-height: 1.7;
}

.login-footer a {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 991.98px) {
    .login-hero {
        display: none;
    }

    .login-form-wrapper {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    .login-form-wrapper {
        padding: 24px;
    }

    .login-form-inner {
        max-width: 100%;
    }

    .login-greeting h3 {
        font-size: 1.2rem;
    }
}

/* --- Monitoring Tabs --- */
.monitoring-tabs {
    border-bottom: 2px solid #e5e7eb;
    gap: 4px;
}

.monitoring-tabs .nav-link {
    color: #6b7280;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    background: transparent;
}

.monitoring-tabs .nav-link:hover {
    color: var(--primary);
    background: var(--primary-bg);
    border-bottom-color: var(--primary-lighter);
}

.monitoring-tabs .nav-link.active {
    color: var(--primary);
    background: #fff;
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.monitoring-tabs .nav-link i {
    font-size: 0.85rem;
}

/* --- Print --- */
@media print {
    .sidebar, .topbar, .footer, .btn, form, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; margin-top: 0 !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content,
    .footer {
        margin-left: 0;
    }

    .sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }
}

@media (max-width: 767.98px) {
    .main-content {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.4rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .table th {
        font-size: 0.72rem;
    }

    .table td {
        font-size: 0.82rem;
    }

    .btn {
        font-size: 0.82rem;
        padding: 0.4rem 0.8rem;
    }

    .matrix-table .cell-inner {
        min-height: 36px;
        font-size: 0.65rem;
    }

    .monitoring-tabs .nav-link {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 0.75rem;
    }

    .stat-card .stat-value {
        font-size: 1.2rem;
    }

    .matrix-table .date-header {
        writing-mode: horizontal-tb;
        transform: none;
        font-size: 0.65rem;
        min-width: 30px;
    }

    .matrix-table .cell-inner {
        min-height: 32px;
        font-size: 0.6rem;
        padding: 2px 1px;
    }
}

/* --- Focus Visible (Accessibility) --- */
:focus-visible {
    outline: 2px solid var(--primary-light);
    outline-offset: 2px;
}

.sidebar-menu .nav-link:focus-visible {
    outline-color: #fff;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .sidebar {
        transition: none;
    }

    .main-content, .footer {
        transition: none;
    }

    .card {
        transition: none;
    }
}
