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

:root {
    --primary: #4F46E5; /* Indigo 600 */
    --primary-hover: #4338CA;
    --secondary: #10B981; /* Emerald 500 */
    --background: #0f172a; /* Slate 900 */
    --surface: #1e293b; /* Slate 800 */
    --surface-glass: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #94a3b8; /* Slate 400 */
    --border: #334155; /* Slate 700 */
    --danger: #ef4444; /* Red 500 */
    --warning: #f59e0b; /* Amber 500 */
    --font-main: 'Outfit', sans-serif;
    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
}

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

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

/* Base gradients and dynamic backgrounds */
.bg-gradient-mesh {
    background: radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.2) 0px, transparent 50%),
                radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.2) 0px, transparent 50%),
                radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
                radial-gradient(at 0% 100%, rgba(244, 63, 94, 0.15) 0px, transparent 50%);
    background-color: var(--background);
    background-attachment: fixed;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.navbar-brand {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a855f7, #3b82f6);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.5px;
}

.navbar-links a {
    color: var(--text-main);
    text-decoration: none;
    margin-left: 2rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.navbar-links a:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-family: var(--font-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 1rem;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.5);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

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

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

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

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

.main-content {
    flex: 1;
    padding: 4rem 0;
}

/* Login Auth Page */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-muted);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* Grid systems */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.course-layout-grid { grid-template-columns: 1fr 300px; gap: 2rem; }

/* Tables */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sidebar Layout */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.app-sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
}
.sidebar-header {
    padding: 1.8rem 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-nav {
    padding: 1.5rem 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    gap: 1rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-link i {
    font-size: 1.25rem;
}
.sidebar-link:hover, .sidebar-link.active {
    color: white;
    background: rgba(79, 70, 229, 0.15);
    border-left-color: var(--primary);
}
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
}
.top-nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 1.2rem 2rem;
    background: var(--surface-glass);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Modal Styles */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 999; display: none; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); width: 100%; max-width: 500px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5); padding: 2rem;
    transform: scale(0.9); opacity: 0; transition: all 0.2s;
}
.modal-overlay.active .modal-box { transform: scale(1); opacity: 1; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom:1px solid rgba(255,255,255,0.05); padding-bottom:1rem; }
.btn-close { background: transparent; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition:0.2s; }
.btn-close:hover { color: var(--danger); }

/* === RESPONSIVE LAYOUT UTILITIES === */
.flex-split {
    display: flex; justify-content: space-between; align-items: center;
}
.sidebar-overlay { display:none; }

/* Desktop Viewer Layout */
.viewer-container { display: flex; height: 100vh; overflow: hidden; }
.viewer-sidebar { width: 300px; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; display: flex; flex-direction: column; transition: transform 0.3s ease; }
.viewer-main { flex: 1; overflow-y: auto; background: var(--background); position: relative; padding: 2rem; }
.btn-mobile-menu { display: none; }

@media (max-width: 768px) {
    .grid-cols-2 { grid-template-columns: 1fr; }
    .grid-cols-3 { grid-template-columns: 1fr; }
    .course-layout-grid { grid-template-columns: 1fr; }
    .navbar { padding: 1rem; flex-direction: column; align-items: stretch !important; transition: all 0.3s; }
    .navbar-header-mobile { display: flex; justify-content: space-between; align-items: center; width: 100%; }
    .student-menu-toggle { display: block !important; background: var(--surface); color: var(--text-main); border: 1px solid var(--border); padding: 0.4rem 0.8rem; border-radius: var(--radius-sm); font-size: 1.3rem; cursor: pointer; }
    .navbar-links { display: none; flex-direction: column; width: 100%; background: rgba(0,0,0,0.15); padding: 1rem; border-radius: var(--radius); gap: 1rem; margin-top: 1rem; }
    .navbar-links.active { display: flex; }
    .navbar-links a, .navbar-links .btn { margin: 0 !important; width: 100%; justify-content: center; }
    
    .flex-split { flex-direction: column; align-items: stretch; gap: 1.5rem; }
    .flex-split > div { width: 100%; text-align: center; }
    
    .container { padding: 0 1rem; }
    .glass-card { padding: 1.5rem; }
    .auth-wrapper { padding: 1rem; min-height: 100dvh; align-items: center; }
    .login-logo-container { margin-bottom: 0.5rem !important; padding: 0 !important; }
    .login-logo { width: 170px !important; transform: scale(1) !important; }

    /* Forms */
    .form-control { font-size: 16px; /* Mencegah zoom iOS */ }

    /* Teacher App Shell Mobile */
    .app-wrapper { flex-direction: column; }
    .app-sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.05); }
    .app-sidebar .sidebar-nav { display:flex; overflow-x: auto; white-space: nowrap; padding: 0.5rem; }
    .sidebar-link { padding: 0.8rem 1rem; flex: 0 0 auto; border-left: none; border-bottom: 2px solid transparent; }
    .sidebar-link.active { border-bottom-color: var(--primary); background: transparent; }
    .app-sidebar > div:last-child { display:none; } /* Hide logout/user profile from horizontal scroller to save space */
    .app-main { width: 100%; }
    .top-nav { justify-content: center; }

    /* Viewer Off-Canvas Logic */
    .viewer-container { display: block; position: relative; }
    .viewer-sidebar { position: fixed; top: 0; left: 0; bottom: 0; z-index: 1000; transform: translateX(-100%); }
    .viewer-sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
    .viewer-main { padding: 1rem; padding-top: 4rem; height: 100vh; }
    .btn-mobile-menu { display: inline-flex; position: fixed; top: 1rem; left: 1rem; z-index: 900; background: var(--surface); color: var(--text-main); border: 1px solid var(--border); padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); font-size: 1.2rem; cursor: pointer; box-shadow:0 4px 6px rgba(0,0,0,0.3); }
    
    /* Overlay for Viewer Sidebar */
    .sidebar-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(2px); z-index: 999; display:none; opacity: 0; transition: opacity 0.3s ease; }
    .sidebar-overlay.open { display: block; opacity: 1; }
    
    /* Hide some visual flair elements */
    .btn { width: 100%; justify-content: center; margin-bottom:0.5rem; }
    td, th { padding: 0.5rem; font-size: 0.85rem; }
}
