:root {
    --primary-color: #2962ff;
    --secondary-color: #1a3c6e;
    --accent-color: #27ae60;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #333;
    --sidebar-width: 250px;
    --transition-speed: 0.3s;
}

/* Fix Assign Teacher Modal Alignment */
.assign-teacher-modal {
    text-align: center;
}

.assign-teacher-modal .swal2-select {
    width: 85% !important;
    margin-top: 10px;
}

.assign-teacher-modal .swal2-actions {
    display: flex !important;
    justify-content: center !important;
    gap: 10px;
}

.assign-teacher-modal .swal2-title {
    text-align: center;
}

.assign-teacher-modal .swal2-popup {
    padding: 25px;
}
 
 .swal-ok-btn { 
     background-color: #6c63ff; 
     color: white; 
     padding: 8px 18px; 
     border-radius: 6px; 
     border: none; 
 } 
 
 .swal-cancel-btn { 
     background-color: #6c757d; 
     color: white; 
     padding: 8px 18px; 
     border-radius: 6px; 
     border: none; 
 } 
 
 .swal-ok-btn:hover { 
     background-color: #5a54d1; 
 } 
 
 .swal-cancel-btn:hover { 
     background-color: #5a6268; 
 }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    color: var(--text-color);
    overflow-x: hidden;
}

/* Sidebar & Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--secondary-color);
    color: #fff;
    position: fixed;
    height: 100%;
    transition: all var(--transition-speed);
    z-index: 1000;
    overflow-y: auto; /* Allow scrolling if content is too tall */
    display: flex;
    flex-direction: column;
}

/* Custom Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.sidebar .brand {
    padding: 20px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Allow list to take available space */
}

.sidebar ul li a {
    display: block;
    padding: 15px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: background var(--transition-speed);
    display: flex;
    align-items: center;
}

.sidebar ul li a i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar ul li a:hover, .sidebar ul li a.active {
    background: var(--primary-color);
    padding-left: 25px; /* Slide effect */
    border-radius: 4px;
    margin: 0 10px;
}

/* Logout Button */
.sidebar ul li a[href*="logout.php"] {
    background-color: #b71c1c;
    color: white;
    margin: 10px 15px;
    text-align: center;
    border-radius: 4px;
    justify-content: center;
    padding: 12px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.sidebar ul li a[href*="logout.php"]:hover {
    background-color: #d32f2f;
    padding-left: 12px; /* No slide */
    transform: translateY(-2px);
}

.sidebar ul li a[href*="logout.php"] i {
    margin-right: 8px;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 20px;
    transition: all var(--transition-speed);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.stat-card {
    border-left: 5px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    opacity: 0.8;
}

/* Forms & Inputs */
input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.3);
}

button, .btn {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s, transform 0.1s;
    display: inline-block;
    text-decoration: none;
}

button:hover, .btn:hover {
    background-color: #357abd;
    transform: scale(1.05);
}

.btn-danger {
    background-color: #e74c3c;
}
.btn-danger:hover { background-color: #c0392b; }

.btn-secondary {
    background-color: #95a5a6;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: var(--secondary-color);
    color: white;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Drag and Drop Specifics */
.draggable-list {
    list-style: none;
    padding: 0;
}

.draggable-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    margin-bottom: 10px;
    padding: 15px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: background 0.2s;
}

.draggable-item:active {
    cursor: grabbing;
}

.draggable-item.sortable-ghost {
    opacity: 0.4;
    background: #e8f0fe;
    border: 1px dashed #4a90e2;
}

.drag-handle {
    margin-right: 15px;
    color: #aaa;
    cursor: grab;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s;
    overflow-y: auto; /* Enable scrolling */
}

/* Ensure SweetAlert2 is always on top of our custom modal */
.swal2-container {
    z-index: 9999 !important;
}

/* Ensure MathLive Virtual Keyboard is on top of SweetAlert2 */
body {
    --keyboard-zindex: 10005;
}
.ML__keyboard {
    z-index: 10005 !important;
}

.modal-content {
    background-color: #fefefe;
    margin: auto; /* Magic Flexbox centering that is safe for overflow */
    padding: 20px;
    border-radius: 8px;
    width: 50%;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    /* Add some vertical spacing */
    margin-top: 50px; 
    margin-bottom: 50px;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}
.close-modal:hover { color: #333; }

/* Login Page Specific */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar .brand, .sidebar span { display: none; }
    .sidebar ul li a { padding: 15px; justify-content: center; }
    .sidebar ul li a i { margin: 0; font-size: 1.5rem; }
    .main-content { margin-left: 70px; width: calc(100% - 70px); }
    .modal-content { width: 90%; }
}

@media print {
    .sidebar, .no-print { display: none !important; }
    .main-content { margin: 0; width: 100%; padding: 0; }
    .card { box-shadow: none; border: none; }
}