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

:root {
  --primary: #3b6fd4;
  --primary-dark: #2a55b0;
  --danger: #d43b3b;
  --success: #2e9c5a;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #dde2ee;
  --text: #1a1f2e;
  --muted: #6b7280;
  --radius: 10px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* LOGIN */
.login-page { display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem 2rem; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,.07); }
.login-card h1 { font-size: 1.8rem; text-align: center; color: var(--primary); }
.login-card .subtitle { text-align: center; color: var(--muted); margin: .4rem 0 1.8rem; font-size: .9rem; }

/* LAYOUT */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--primary); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; padding: 1.5rem 0; }
.sidebar h2 { font-size: 1.1rem; padding: 0 1.2rem 1.2rem; border-bottom: 1px solid rgba(255,255,255,.2); }
.sidebar nav a { display: block; padding: .7rem 1.2rem; color: rgba(255,255,255,.85); text-decoration: none; font-size: .9rem; transition: background .15s; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.15); color: #fff; }
.sidebar .logout { margin-top: auto; padding: 1rem 1.2rem 0; }
.main { flex: 1; padding: 2rem; overflow-y: auto; }
.main h1 { font-size: 1.5rem; margin-bottom: 1.5rem; }

/* CARDS */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.card h2 { font-size: 1.1rem; margin-bottom: 1rem; }

/* FORMS */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--muted); }
.field input, .field select { width: 100%; padding: .6rem .8rem; border: 1px solid var(--border); border-radius: 6px; font-size: .95rem; background: #fff; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,111,212,.15); }

/* BUTTONS */
.btn { padding: .6rem 1.2rem; border: none; border-radius: 6px; font-size: .9rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; width: 100%; margin-top: .5rem; padding: .75rem; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b52e2e; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #237848; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }

/* TABLE */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .6rem .8rem; font-size: .8rem; color: var(--muted); border-bottom: 2px solid var(--border); }
td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* UPLOAD ZONE */
.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 3rem 2rem; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.drop-zone.drag-over { border-color: var(--primary); background: rgba(59,111,212,.05); }
.drop-zone .icon { font-size: 3rem; }
.drop-zone p { color: var(--muted); margin: .5rem 0; }
.drop-zone input[type=file] { display: none; }

/* FILE LIST */
.file-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 0; border-bottom: 1px solid var(--border); }
.file-item:last-child { border-bottom: none; }
.file-icon { font-size: 1.4rem; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .78rem; color: var(--muted); }
.file-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* ALERTS */
.error-msg { color: var(--danger); font-size: .85rem; margin-top: .6rem; }
.success-msg { color: var(--success); font-size: .85rem; margin-top: .6rem; }
.hidden { display: none !important; }

/* UPLOAD PROGRESS */
.progress-list { margin-top: 1rem; }
.progress-item { margin-bottom: .5rem; }
.progress-item .name { font-size: .85rem; margin-bottom: .2rem; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); transition: width .3s; }

/* BADGE */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-teacher { background: #d1fae5; color: #065f46; }
.badge-parent { background: #dbeafe; color: #1e40af; }

/* THUMBNAIL */
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; cursor: zoom-in; flex-shrink: 0; border: 1px solid var(--border); transition: opacity .15s; }
.thumb:hover { opacity: .85; }
.thumb-placeholder { width: 72px; height: 72px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0; }

/* LIGHTBOX */
.lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 1000; align-items: center; justify-content: center; padding: 1.5rem; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; object-fit: contain; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
.lightbox-close { position: absolute; top: 1rem; right: 1.2rem; color: #fff; font-size: 2rem; cursor: pointer; line-height: 1; background: none; border: none; opacity: .8; }
.lightbox-close:hover { opacity: 1; }
.lightbox-caption { position: absolute; bottom: 1.2rem; left: 50%; transform: translateX(-50%); color: #fff; font-size: .85rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80vw; }

@media (max-width: 640px) {
  .sidebar { display: none; }
  .main { padding: 1rem; }
}
