/* Modern Design System - HKASOFT */
:root {
    --primary: #4F46E5;
    /* Indigo 600 */
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #64748B;

    --bg-body: #F1F5F9;
    --bg-card: #FFFFFF;

    --text-main: #0F172A;
    --text-muted: #64748B;

    --border: #E2E8F0;
    --radius: 12px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    line-height: 1.6;
}

/* Layout & Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0 0 1rem 0;
    font-weight: 700;
    letter-spacing: -0.025em;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    flex-shrink: 0;
}

.brand {
    padding: 1.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, #818CF8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.05em;
}

.nav {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
}

.nav-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1.5rem 0 0.5rem 1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--secondary);
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item i {
    font-size: 1.25rem;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-item.active {
    background: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-body);
}

.topbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
}

.content {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Components */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    background: var(--primary);
    color: white;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: #DC2626;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: #F8FAFC;
    transition: all 0.2s;
    box-sizing: border-box;
}

.input:focus {
    outline: none;
    background: #FFF;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #F8FAFC;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #F8FAFC;
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 4px solid transparent;
    font-weight: 500;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #EF4444;
}


/* Mobile & Responsive */
@media (max-width: 991px) {
    .app-wrapper {
        position: relative;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        height: 100vh;
        transition: left 0.3s ease;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-toggle {
        display: block !important;
        font-size: 1.5rem;
        margin-right: 1rem;
        cursor: pointer;
        color: var(--text-main);
    }

    .content {
        padding: 1rem;
    }

    /* Grids to single column */
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* Flexbox adjustments */
    .flex {
        flex-direction: column;
        align-items: stretch;
    }

    .flex>* {
        margin-right: 0 !important;
        margin-bottom: 1rem;
        width: 100%;
    }

    .flex>*:last-child {
        margin-bottom: 0;
    }

    /* Tables horizontal scroll */
    .card {
        overflow-x: hidden;
        /* Prevent card overflow */
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Card internal padding */
    .card {
        padding: 1.25rem;
    }

    /* Typography adjustments */
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    /* Login Form Specific */
    .login-container {
        width: 90% !important;
        padding: 1.5rem !important;
    }
}

.mobile-toggle {
    display: none;
}

/* Grid System Helper */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.grid-4 {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

/* Utility */
.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Dashboard Role Headers */
.role-header {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.role-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.role-header p {
    opacity: 0.9;
    font-size: 1.05rem;
    margin: 0;
}

.role-header-student {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: white;
    border: none;
}

.role-header-teacher {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border: none;
}

.role-header-guidance {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: white;
    border: none;
}

.role-header-accountant {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: white;
    border: none;
}

/* Action Stack */
.action-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-stack .btn-outline {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-main);
}

.action-stack .btn-outline:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--primary);
    color: var(--primary);
}


/* Auth Pages */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 2.5rem !important;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.text-center {
    text-align: center;
}

.mb-4 {
    margin-bottom: 1.5rem;
}