@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Sinhala:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #ec4899;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border-color: #e2e8f0;
}



* {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Sinhala', 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.glass-card {
    background: var(--card-bg);
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    padding: 0.5rem 1.2rem;
    border-radius: 0.5rem;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s ease;
    border: 1px solid var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background-color: #e0e7ff;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control, select, textarea, input[type="file"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: 'Noto Sans Sinhala', 'Outfit', sans-serif;
    font-size: 1rem;
    transition: all 0.3s;
    background-color: var(--bg-color);
    color: var(--text-main);
    box-sizing: border-box;
}

.form-control:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[type="checkbox"], input[type="radio"] {
    width: auto;
    accent-color: var(--primary-color);
    transform: scale(1.2);
    margin-right: 0.5rem;
    cursor: pointer;
}

.navbar {
    background: var(--card-bg);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 5%;
}

.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-4 { margin-bottom: 2rem; }
.text-muted { color: var(--text-muted); }

/* Responsive Table */
.table-responsive {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}
th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
th {
    background-color: var(--bg-color);
    font-weight: 600;
    color: var(--text-main);
}
tr:hover td {
    background-color: var(--bg-color);
}

/* Dashboard Grid */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }

/* Ad Banner Area */
.ad-banner {
    background: transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3rem 0;
    min-height: 90px;
    border-radius: 0.5rem;
    text-align: center;
    font-weight: 500;
}

@media (max-width: 768px) {
    .ad-banner { margin: 2rem 0; }
}

.hero-section {
    text-align: center;
    padding: 6rem 5%;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, var(--bg-color) 100%);
    border-bottom: 1px solid var(--border-color);
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 800px;
    margin: 0 auto 2rem auto;
}

.bg-card {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
}


.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}
.badge-active { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-inactive { background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Alert Boxes */
.alert-blue {
    background: rgba(59, 130, 246, 0.1);
    border-left: 4px solid #3b82f6;
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}
.alert-blue h4 { color: #3b82f6; margin: 0; }
.alert-blue p { color: var(--text-main); margin: 0.5rem 0 0 0; }

.card-red {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: var(--danger) !important;
}
.card-red h3, .card-red h1 { color: var(--danger) !important; }

/* Paper Cards */
.paper-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
    transition: all 0.3s;
}
.paper-card:hover {
    transform: translateX(5px);
    border-color: var(--primary-color);
}
.status-red { border-left: 5px solid var(--danger); }
.status-green { border-left: 5px solid var(--success); }

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .hamburger {
        display: block;
    }
    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        padding: 1rem;
        box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
        border-top: 1px solid var(--border-color);
        z-index: 9999;
        align-items: stretch;
    }
    .nav-links a {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
    }
    .nav-links a:last-child {
        border-bottom: none;
    }
    .nav-links.show {
        display: flex;
    }
    .hero-title {
        font-size: 1.8rem;
    }
    .navbar-brand {
        font-size: 1.2rem;
    }
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    .glass-card {
        padding: 1.5rem !important; /* Reduced padding on mobile */
    }
    .main-content {
        padding: 1rem !important;
    }
    .topbar {
        padding: 0.75rem 1rem !important;
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    .responsive-flex {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    /* Dashboard Mobile Sidebar */
    .admin-layout, .student-layout { position: relative; flex-direction: column; }
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 250px;
        z-index: 10000;
        display: flex; /* Always flex */
        background: var(--card-bg);
        transition: left 0.3s ease-in-out;
        box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    }
    .sidebar.active {
        left: 0;
    }
    /* Overlay background when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 9999;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--primary-color);
        margin-right: 1rem;
    }
    .topbar {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
    }
    .topbar h2 {
        font-size: 1.25rem;
    }
    
    /* Responsive Table as Cards */
    .mobile-card-table table, 
    .mobile-card-table thead, 
    .mobile-card-table tbody, 
    .mobile-card-table th, 
    .mobile-card-table td, 
    .mobile-card-table tr {
        display: block;
    }
    .mobile-card-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .mobile-card-table tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 1rem;
        background: var(--card-bg);
        padding: 1rem;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }
    .mobile-card-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        border-bottom: 1px dashed var(--border-color);
        padding: 0.75rem 0;
        text-align: right;
    }
    .mobile-card-table td:last-child {
        border-bottom: 0;
        padding-bottom: 0;
        justify-content: center;
        margin-top: 0.5rem;
    }
    .mobile-card-table td:last-child::before {
        display: none;
    }
    .mobile-card-table td:last-child a {
        width: 100%;
        text-align: center;
    }
    .mobile-card-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-align: left;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn { display: none; }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-soft {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.glass-card {
    animation: fadeInUp 0.6s ease-out forwards;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.hero-title {
    animation: fadeInUp 0.8s ease-out forwards;
}

.hero-subtitle {
    animation: fadeInUp 1s ease-out forwards;
}

.btn-primary {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.btn-primary:active::after {
    width: 200px;
    height: 200px;
}

/* Preloader */
#global-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
}
.loader-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
