:root {
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --secondary-color: #ec4899;
    /* Pink 500 */
    --accent-color: #8b5cf6;
    /* Violet 500 */
    --danger-color: #ef4444;
    /* Red 500 */
    --success-color: #10b981;
    /* Emerald 500 */
    --text-color: #1f2937;
    /* Gray 800 */
    --text-light: #6b7280;
    /* Gray 500 */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.3);
    --shadow-md: 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);
    --radius-lg: 1rem;
    --radius-md: 0.5rem;
    --font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Layout Utilities --- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* --- Glassmorphism Cards --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* --- Typography --- */
h1,
h2,
h3 {
    color: #111827;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

p {
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* --- Buttons --- */
button {
    cursor: pointer;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

button.secondary {
    background-color: transparent;
    border: 1px solid var(--text-light);
    color: var(--text-light);
}

button.secondary:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
}

button.danger {
    background-color: var(--danger-color);
}

button.danger:hover {
    background-color: #dc2626;
}

/* --- Forms --- */
input[type="text"],
input[type="email"],
select,
input[type="file"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius-md);
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* --- Navbar --- */
nav {
    background: rgba(220, 225, 235, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-md);
}

/* --- Footer --- */
.site-footer {
    background: rgba(220, 225, 235, 0.95);
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-color);
    border-top: 2px solid rgba(0, 0, 0, 0.05);
    margin-top: auto;
    width: 100%;
}

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

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

/* --- Grid Layouts --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.course-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    cursor: pointer;
    border-left: 5px solid var(--accent-color);
}

/* --- Floating Action Button (FAB) --- */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s;
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modalPop 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modalPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.close-modal {
    background: none;
    color: var(--text-light);
    font-size: 1.5rem;
    padding: 0;
}

.close-modal:hover {
    color: var(--danger-color);
    background: none;
    transform: none;
}

/* --- Tables & Stats --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f9fafb;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

/* --- Status Messages --- */
.status-message {
    padding: 12px;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-weight: 500;
    text-align: center;
}

.status-message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.status-message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

/* --- Countdown Timer --- */
.timer-display {
    font-size: 3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--primary-color);
    margin: 1rem 0;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

/* --- Login Page Specific --- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    text-align: center;
}

/* --- Global Loading Overlay --- */
.global-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Highest priority */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.global-loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(79, 70, 229, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}