/* ==========================================================
   File Portal - Main Stylesheet
   Clean, simple design with generous whitespace.
   ========================================================== */

:root {
  --color-bg: #f6f7fb;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #eef2ff;
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5em 0;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ---------------- Layout ---------------- */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--color-text);
}

.topbar .brand img {
  height: 32px;
  width: auto;
  border-radius: 6px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar nav a, .topbar nav .user-chip {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 14px;
}

.topbar nav a:hover { background: var(--color-bg); text-decoration: none; color: var(--color-text); }
.topbar nav a.active { color: var(--color-primary); background: var(--color-primary-light); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.container.narrow { max-width: 460px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header p { color: var(--color-text-muted); margin: 4px 0 0; }

/* ---------------- Cards ---------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body { padding: 24px; }
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 16px; }

/* ---------------- Stat cards ---------------- */

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

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--color-text);
}

.stat-card .stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  margin-bottom: 12px;
  font-size: 18px;
}

/* ---------------- Forms ---------------- */

label {
  display: block;
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--color-text);
}

.form-group { margin-bottom: 18px; }
.form-hint { font-size: 12.5px; color: var(--color-text-muted); margin-top: 4px; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  margin: 0;
  font-size: 14px;
}

.checkbox-grid input { width: auto; }

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- Tables ---------------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; background: #fafafc; }
tbody tr:hover { background: #fafafc; }
tbody tr:last-child td { border-bottom: none; }

.sort-link { color: var(--color-text-muted); font-weight: 600; }
.sort-link:hover { color: var(--color-text); }
.sort-link.active { color: var(--color-primary); }

/* ---------------- Badges / tags ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.badge + .badge { margin-left: 4px; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }

/* ---------------- Alerts / flash messages ---------------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: #a7f3d0; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border-color: #fecaca; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: #fde68a; }

/* ---------------- Login page ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 36px;
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}

.login-card .brand img { height: 48px; margin-bottom: 12px; }
.login-card .brand h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .brand p { color: var(--color-text-muted); font-size: 13.5px; margin: 0; }

/* ---------------- Admin layout ---------------- */

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

.admin-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 20px 14px;
}

.admin-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
  font-weight: 700;
  font-size: 16px;
}
.admin-sidebar .brand img { height: 28px; border-radius: 6px; }

.admin-sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}
.admin-sidebar a:hover { background: var(--color-bg); text-decoration: none; color: var(--color-text); }
.admin-sidebar a.active { background: var(--color-primary-light); color: var(--color-primary); }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  height: 64px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.admin-content { padding: 28px; }

/* ---------------- Utility ---------------- */

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 13px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--color-text-muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 12px; }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  align-items: center;
}
.filter-bar select, .filter-bar input[type="text"] { width: auto; min-width: 180px; }

@media (max-width: 720px) {
  .admin-sidebar { display: none; }
  .topbar nav { gap: 0; }
  .container { padding: 20px 16px 48px; }
}
