:root {
  --bg: #f0f2f5;
  --surface: #fff;
  --panel: #f8f9fb;
  --border: #e8eaee;
  --text: #1a1a2e;
  --text-2: #555;
  --muted: #888;
  --btn-bg: #f0f1f5;
  --btn-bg-hover: #e8e9ef;
  --brand-ink: #8b0000;
  --tag-amber: #d97706;
  --tag-teal: #0d9488;
  --opt-sel: #f0f0ff;
  --msg-success-bg: #dcfce7;
  --msg-success-text: #16a34a;
  --msg-success-border: #bbf7d0;
  --msg-error-bg: #fee2e2;
  --msg-error-text: #dc2626;
  --msg-error-border: #fecaca;
  --msg-warning-bg: #fef3c7;
  --msg-warning-text: #d97706;
  --msg-warning-border: #fde68a;
}

html[data-theme="dark"] {
  --bg: #0f141f;
  --surface: #1a2233;
  --panel: #232d42;
  --border: #2f3a52;
  --text: #e9edf5;
  --text-2: #b6bfd2;
  --muted: #8d96a9;
  --btn-bg: #28324a;
  --btn-bg-hover: #33405e;
  --brand-ink: #ff8282;
  --tag-amber: #fbbf24;
  --tag-teal: #2dd4bf;
  --opt-sel: rgba(99, 102, 241, 0.22);
  --msg-success-bg: #052e16;
  --msg-success-text: #4ade80;
  --msg-success-border: #14532d;
  --msg-error-bg: #450a0a;
  --msg-error-text: #f87171;
  --msg-error-border: #7f1d1d;
  --msg-warning-bg: #451a03;
  --msg-warning-text: #fbbf24;
  --msg-warning-border: #78350f;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 600px 400px at 10% 20%, rgba(139, 0, 0, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 500px 400px at 90% 80%, rgba(139, 0, 0, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 44px 36px 36px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 32px rgba(0, 0, 0, 0.06);
  transition: all 0.2s;
}

.card-header {
  text-align: center;
  margin-bottom: 32px;
}

.logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  background: linear-gradient(135deg, #8b0000, #a30000);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 16px rgba(139, 0, 0, 0.2);
}

.card-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.card-header p {
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: titlecase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
}

.input-wrapper .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 16px;
  pointer-events: none;
  transition: color 0.2s;
}

.input-wrapper:focus-within .icon {
  color: var(--brand-ink);
}

.form-control {
  width: 100%;
  padding: 13px 16px 13px 44px;
  font-size: 15px;
  color: var(--text);
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: all 0.2s;
  font-family: inherit;
}

.form-control::placeholder {
  color: var(--muted);
}

.form-control:focus {
  border-color: var(--brand-ink);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

select.form-control {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #8b0000, #a30000);
  color: #fff;
  box-shadow: 0 4px 12px rgba(139, 0, 0, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 0, 0, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--btn-bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--btn-bg-hover);
}

.btn-danger {
  background: var(--msg-error-bg);
  color: var(--msg-error-text);
  border: 1px solid var(--msg-error-border);
}

.btn-danger:hover:not(:disabled) {
  background: var(--msg-error-border);
}

.btn-link {
  background: none;
  color: var(--muted);
  padding: 8px;
  font-size: 13px;
  font-weight: 400;
  width: auto;
}

.btn-link:hover {
  color: var(--brand-ink);
}

.form-footer {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 18px;
}

.message {
  margin-top: 14px;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 8px;
  text-align: center;
  line-height: 1.4;
  display: none;
}

.message.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

.message.success {
  background: var(--msg-success-bg);
  color: var(--msg-success-text);
  border: 1px solid var(--msg-success-border);
}

.message.error {
  background: var(--msg-error-bg);
  color: var(--msg-error-text);
  border: 1px solid var(--msg-error-border);
}

.message.warning {
  background: var(--msg-warning-bg);
  color: var(--msg-warning-text);
  border: 1px solid var(--msg-warning-border);
}

.timer {
  text-align: center;
  margin-bottom: 22px;
  padding: 14px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.timer-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.timer-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--brand-ink);
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.timer.expired .timer-value {
  color: var(--muted);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

@media (max-width: 480px) {
  .card {
    padding: 32px 20px 28px;
    border-radius: 16px;
  }

  .container {
    padding: 12px;
  }
}

/* ===== Admin Dashboard ===== */

body.dashboard-body {
  display: block;
  background: var(--bg);
  padding: 0;
}

body.dashboard-body::before {
  display: none;
}

.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.sidebar-logo .logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #8b0000, #a30000);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.sidebar-logo .logo-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Sidebar link grupları: her grup ayrı kart gibi görünür */
.nav-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 12px;
}

.nav-card:last-child {
  margin-bottom: 0;
}

.nav-card .nav-item:hover {
  background: var(--surface);
}

.nav-card .nav-section-title {
  padding: 4px 10px 6px;
}

.nav-card .nav-section-title:first-child {
  padding-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
  color: var(--muted);
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item:hover i {
  color: var(--text-2);
}

.nav-item.active {
  background: rgba(139, 0, 0, 0.08);
  color: var(--brand-ink);
}

.nav-item.active i {
  color: var(--brand-ink);
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 20px 14px 6px;
}

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b0000, #a30000);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.topbar-user .user-name {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.topbar-user .user-role {
  font-size: 11px;
  color: var(--muted);
}

.topbar .btn-logout {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar .btn-logout:hover {
  background: var(--msg-error-bg);
  color: var(--msg-error-text);
  border-color: var(--msg-error-border);
}

/* Content area */
.content-area {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.content-header {
  margin-bottom: 24px;
}

.content-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.content-header p {
  font-size: 14px;
  color: var(--muted);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
}

.stat-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Section titles */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i {
  color: var(--brand-ink);
  font-size: 15px;
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

#quickLinks {
  grid-template-columns: repeat(4, 1fr);
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.report-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-card h4 i {
  color: var(--brand-ink);
  font-size: 14px;
}

.link-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  transition: all 0.2s;
  display: block;
}

.link-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  border-color: var(--border);
  transform: translateY(-2px);
}

.link-card .card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(139, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--brand-ink);
  margin-bottom: 14px;
}

.link-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.link-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.link-card .card-icon {
  position: relative;
}

@keyframes fr-pulse {
  0%, 100% { opacity:1; box-shadow: 0 0 16px rgba(220,38,38,0.5); transform:scale(1); }
  25% { opacity:0.7; box-shadow: 0 0 40px rgba(220,38,38,0.9); transform:scale(1.02); }
  50% { opacity:1; box-shadow: 0 0 16px rgba(220,38,38,0.5); transform:scale(1); }
  75% { opacity:0.85; box-shadow: 0 0 30px rgba(220,38,38,0.75); transform:scale(1.01); }
}

.link-card.highlight {
  animation: fr-pulse 1.2s ease-in-out infinite;
}

.card-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Announcements */
.announcements-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.announcement-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.announcement-item .ann-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}

.ann-tag.admin { background: rgba(139, 0, 0, 0.1); color: #8b0000; }
.ann-tag.all { background: rgba(139, 0, 0, 0.1); color: #8b0000; }
.ann-tag.lise { background: rgba(245, 158, 11, 0.1); color: var(--tag-amber); }
.ann-tag.ortaokul { background: rgba(13, 148, 136, 0.1); color: var(--tag-teal); }

.announcement-item h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.announcement-item p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.4;
  margin-bottom: 6px;
}

.announcement-item .ann-date {
  font-size: 11px;
  color: var(--muted);
}

/* Users Table */
.users-table-wrapper {
  overflow-x: auto;
  margin-bottom: 28px;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.users-table thead th {
  text-align: left;
  padding: 13px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.users-table tbody tr {
  transition: background 0.12s;
}

.users-table tbody tr:hover {
  background: var(--panel);
}

.users-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}

.users-table tbody tr:last-child td {
  border-bottom: none;
}

.users-table .cell-email {
  color: var(--text);
  font-weight: 500;
}

.users-table .cell-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.users-table .cell-actions {
  text-align: right;
  white-space: nowrap;
}

.role-select {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
  min-width: 140px;
}

.role-select:hover {
  border-color: var(--border);
}

.role-select:focus {
  border-color: var(--brand-ink);
}

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
  background: transparent;
  color: var(--muted);
}

.btn-icon:hover {
  background: var(--btn-bg);
  color: var(--text-2);
}

.btn-icon-danger:hover {
  background: var(--msg-error-bg);
  color: var(--msg-error-text);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  animation: fadeIn 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-2);
}

.modal-body {
  padding: 24px 28px;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body p {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 28px 24px;
}

.modal-footer .btn {
  padding: 10px 20px;
  font-size: 13px;
  width: auto;
}

/* Hamburger toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

/* Theme toggle */
.theme-toggle {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--btn-bg-hover);
  color: var(--text);
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    bottom: 0;
    z-index: 100;
    background: var(--surface);
    transition: left 0.25s ease;
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.1);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .sidebar-toggle {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .content-area {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cards-grid,
  #quickLinks {
    grid-template-columns: 1fr;
  }
}
