/* ===== CSS CUSTOM PROPERTIES (DESIGN TOKENS) ===== */
:root {
  /* Color Palette */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --success-50: #ecfdf5;
  --success-500: #10b981;
  --success-600: #059669;

  --error-50: #fef2f2;
  --error-500: #ef4444;
  --error-600: #dc2626;

  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  /* Semantic Colors */
  --color-primary: var(--primary-600);
  --color-primary-hover: var(--primary-700);
  --color-primary-light: var(--primary-50);
  --color-secondary: var(--gray-600);
  --color-success: var(--success-500);
  --color-error: var(--error-500);
  --color-warning: var(--warning-500);
  --color-text: var(--gray-900);
  --color-text-light: var(--gray-600);
  --color-text-muted: var(--gray-500);
  --color-background: #ffffff;
  --color-background-secondary: var(--gray-50);
  --color-border: var(--gray-200);
  --color-border-light: var(--gray-100);

  /* Typography */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-family-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-size-4xl: 2.25rem;   /* 36px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Spacing */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  /* Z-Index */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal: 1040;
  --z-popover: 1050;
  --z-tooltip: 1060;
}

/* ===== RESET & BASE STYLES ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: var(--line-height-normal);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  line-height: var(--line-height-normal);
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-light);
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* ===== LAYOUT COMPONENTS ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-sm {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.container-lg {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

/* ===== HEADER/NAVBAR ===== */
.topbar {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: white;
  padding: var(--space-4) var(--space-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  width: 100%;
  min-height: 60px;
  flex-wrap: nowrap;
}

.topbar h2 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin: 0;
  color: white;
  flex-shrink: 0;
}

.topbar .user-info {
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-left: auto;
  white-space: nowrap;
}

.logout-btn {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-weight: var(--font-weight-medium);
}

.logout-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
}

/* ===== MAIN CONTENT ===== */
main {
  min-height: calc(100vh - 140px);
  padding: var(--space-8) 0;
}

.centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: var(--space-16);
}

.hero-content {
  max-width: 800px;
  margin: 0 auto;
}

.title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-6);
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-description {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  margin-bottom: var(--space-8);
  line-height: var(--line-height-relaxed);
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.features-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-8);
  max-width: 1000px;
  margin: 0 auto;
}

.feature-item {
  text-align: center;
  padding: var(--space-6);
  background: var(--color-background);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.feature-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.feature-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.feature-item h3 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.feature-item p {
  color: var(--color-text-light);
  font-size: var(--font-size-base);
  line-height: var(--line-height-relaxed);
  margin: 0;
}

/* ===== BUTTONS ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left var(--transition-normal);
}

.button:hover::before {
  left: 100%;
}

.button.primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  color: white;
}

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

.button.secondary:hover {
  background: var(--color-background-secondary);
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
}

.button.danger {
  background: linear-gradient(135deg, var(--error-500), var(--error-600));
  color: white;
}

.button.danger:hover {
  background: linear-gradient(135deg, var(--error-600), #b91c1c);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  color: white;
}

.button-group {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

/* ===== FORMS ===== */
.auth-form {
  max-width: 500px;
  margin: 0 auto;
  padding: var(--space-8);
  background: var(--color-background);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border-light);
}

.auth-form h1 {
  text-align: center;
  margin-bottom: var(--space-8);
  color: var(--color-text);
}

.form-group {
  margin-bottom: var(--space-6);
}

.form-group label {
  display: block;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="file"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-size-base);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-background);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group input::placeholder {
  color: var(--color-text-muted);
}

.req {
  color: var(--color-error);
  margin-left: var(--space-1);
}

.form-buttons {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

input[type="submit"],
input[type="reset"] {
  flex: 1;
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

input[type="submit"] {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
}

input[type="submit"]:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

input[type="reset"] {
  background: var(--color-background-secondary);
  color: var(--color-text);
  border: 2px solid var(--color-border);
}

input[type="reset"]:hover {
  background: var(--color-border);
  border-color: var(--color-text-muted);
}

.alt-link {
  margin-top: var(--space-6);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

/* ===== DASHBOARD SPECIFIC ===== */
.search-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding: var(--space-4);
  background: var(--color-background-secondary);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
}

.dashboard-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.search-bar {
  position: relative;
  display: flex;
  gap: var(--space-3);
}

.filter-controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.filter-select {
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-background);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-select:hover {
  border-color: var(--primary-400);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* File category styling */
.file-category {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
}

.category-documents {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-600);
}

.category-images {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-600);
}

.category-presentations {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning-600);
}

.category-spreadsheets {
  background: rgba(139, 92, 246, 0.1);
  color: var(--purple-600);
}

.category-archives {
  background: rgba(107, 114, 128, 0.1);
  color: var(--gray-600);
}

.category-other {
  background: rgba(156, 163, 175, 0.1);
  color: var(--gray-500);
}

/* Upload Section Styling */
.upload-section {
  background: var(--color-background);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-top: var(--space-8);
}

.upload-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.upload-header h3 {
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.upload-header p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.upload-form {
  max-width: 600px;
  margin: 0 auto;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  align-items: start;
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-row .form-group {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
}

.required {
  color: var(--color-error);
}

.file-input-wrapper {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
}

.file-input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 1;
}

.file-input-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
  width: 100%;
  box-sizing: border-box;
}

.file-input-label:hover {
  border-color: var(--primary-400);
  background: rgba(59, 130, 246, 0.05);
}

.file-input-text {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.file-input-icon {
  font-size: var(--font-size-lg);
}

.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* Auth form select styling */
.auth-form select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  font-size: var(--font-size-base);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.auth-form select:hover {
  border-color: var(--primary-400);
}

.auth-form select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select:hover {
  border-color: var(--primary-400);
}

.form-select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  font-size: var(--font-size-base);
  color: var(--color-text);
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  font-size: var(--font-size-base);
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-help {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.form-actions {
  text-align: center;
  margin-top: var(--space-6);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
}

.button-icon {
  font-size: var(--font-size-lg);
}

/* User Role Styling */
.user-role {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
  margin-left: var(--space-2);
}

.role-admin {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.role-contributor {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.role-viewer {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success-600);
}

/* Disabled button styling */
.button.disabled {
  background: var(--color-background-secondary) !important;
  color: var(--color-text-secondary) !important;
  border-color: var(--color-border) !important;
  cursor: not-allowed !important;
  opacity: 0.6;
  pointer-events: auto; /* Allow click for alert */
}

.button.disabled:hover {
  background: var(--color-background-secondary) !important;
  color: var(--color-text-secondary) !important;
  border-color: var(--color-border) !important;
  transform: none !important;
  box-shadow: none !important;
}

/* Disabled upload section */
.upload-disabled {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  background: var(--color-background-secondary);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--color-border);
}

.upload-disabled-content {
  text-align: center;
  padding: var(--space-6);
}

.upload-disabled-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.upload-disabled-content h4 {
  color: var(--color-text);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-lg);
}

.upload-disabled-content p {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
}

/* Header actions styling */
.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-actions .button {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  text-decoration: none;
}

.search-bar input[type="text"] {
  flex: 1;
  padding: var(--space-3) var(--space-4) var(--space-3) 40px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  background: var(--color-background);
  position: relative;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px 16px;
}

.search-bar button {
  padding: var(--space-3) var(--space-6);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-bar button:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ===== FILE CARDS ===== */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.file-card {
  background: var(--color-background);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.file-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.file-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.file-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-100), var(--primary-200));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-lg);
  color: var(--primary-600);
}

.file-info h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  color: var(--color-text);
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.file-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-light);
}

.file-meta-item strong {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.file-tag {
  background: var(--primary-50);
  color: var(--primary-700);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.file-actions {
  display: flex;
  gap: var(--space-2);
}

.file-actions .button {
  flex: 1;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
}

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-light);
}

.empty-state h3 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

.empty-state p {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-6);
}

/* ===== UPLOAD FORM ===== */
.upload-form {
  background: var(--color-background);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  text-align: center;
  transition: all var(--transition-fast);
}

.upload-form:hover {
  border-color: var(--color-primary);
  background: var(--primary-50);
}

.upload-form h3 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-6);
  color: var(--color-text);
}

.upload-form form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 500px;
  margin: 0 auto;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  gap: var(--space-2);
}

.upload-form input[type="file"] {
  width: 100%;
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
  cursor: pointer;
}

.upload-form input[type="text"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-background);
}

.upload-form button {
  align-self: flex-start;
  padding: var(--space-3) var(--space-8);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.upload-form button:hover {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ===== ALERTS ===== */
.alert {
  background: var(--color-background);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  margin: 0 auto;
}

.alert h1 {
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.alert p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
  margin-bottom: var(--space-6);
}

/* ===== FOOTER ===== */
footer {
  background: var(--gray-50);
  border-top: 1px solid var(--color-border-light);
  padding: var(--space-6) 0;
  text-align: center;
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .container {
    padding: 0 var(--space-3);
  }

  .topbar {
    padding: var(--space-3) var(--space-4);
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }

  .topbar h2 {
    font-size: var(--font-size-lg);
  }

  .title {
    font-size: var(--font-size-3xl);
  }

  .button-group {
    flex-direction: column;
    align-items: center;
  }

  .button {
    width: 100%;
    max-width: 300px;
  }

  .search-bar {
    flex-direction: column;
  }

  .file-grid {
    grid-template-columns: 1fr;
  }

  .file-actions {
    flex-direction: column;
  }

  .form-buttons {
    flex-direction: column;
  }

  .auth-form {
    padding: var(--space-6);
    margin: var(--space-4);
  }
}

@media (max-width: 480px) {
  .auth-form {
    padding: var(--space-4);
    margin: var(--space-2);
  }

  .upload-form {
    padding: var(--space-4);
  }

  .file-card {
    padding: var(--space-4);
  }
}

/* ===== ADMIN DASHBOARD ===== */
.admin-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.admin-header h1 {
  font-size: var(--font-size-3xl);
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.admin-header p {
  font-size: var(--font-size-lg);
  color: var(--color-text-light);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-background);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card h3 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.stat-card p {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin: 0;
}

.users-section {
  background: var(--color-background);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.section-header h2 {
  margin: 0;
  color: var(--color-text);
}

.search-controls {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.search-input {
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  min-width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: var(--space-6);
}

.user-card {
  background: var(--color-background);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.user-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.user-avatar {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-lg);
}

.user-card .user-info {
  flex: 1;
  min-width: 0; /* Allow flex item to shrink */
}

.user-card .user-info h3 {
  margin: 0 0 var(--space-1) 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
  word-break: break-word;
}

.user-email {
  color: var(--color-text-light);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-1) 0;
  word-break: break-all;
  overflow-wrap: break-word;
  line-height: 1.3;
}

.user-id {
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  margin: 0;
  white-space: nowrap;
}

.user-details {
  margin-bottom: var(--space-4);
}

.user-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
}

.meta-item strong {
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  min-width: 60px;
}

.user-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.role-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.role-controls label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  min-width: 80px;
}

.role-select {
  padding: var(--space-1) var(--space-2);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--color-background);
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.role-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.update-role-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.action-buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.revoke-btn, .delete-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
}

.current-user-badge {
  background: var(--primary-50);
  color: var(--primary-700);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-align: center;
}

.protected-badge {
  background: #f59e0b;
  color: white;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-align: center;
  margin-left: var(--space-2);
}

.delete-btn.disabled {
  background: #6b7280;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.delete-btn.disabled:hover {
  background: #6b7280;
  color: #9ca3af;
  transform: none;
}

/* Disabled role controls */
.role-select.disabled {
  background: #6b7280;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
  border-color: #6b7280;
}

.role-select.disabled:hover {
  background: #6b7280;
  color: #9ca3af;
  border-color: #6b7280;
}

.update-role-btn.disabled {
  background: #6b7280;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.update-role-btn.disabled:hover {
  background: #6b7280;
  color: #9ca3af;
  transform: none;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  align-items: center;
  justify-content: center;
}

#confirmModal .modal-content {
  background: var(--color-background);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  text-align: center;
}

#confirmModal .modal-content h3 {
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

#confirmModal .modal-content p {
  margin-bottom: var(--space-6);
  color: var(--color-text-light);
  line-height: var(--line-height-relaxed);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* ===== UTILITY CLASSES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.grid { display: grid; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

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

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

/* ===== LOADING STATES ===== */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Preview Modal Styles */
.preview-modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 60px; /* Start below the header */
  width: 100vw;
  height: calc(100vh - 60px); /* Full height minus header */
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 20px;
  box-sizing: border-box;
}

.modal-content {
  background: var(--color-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 100px); /* Account for header + padding */
  width: auto;
  height: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  margin: auto;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border-light);
}

.modal-header h3 {
  margin: 0;
  color: var(--color-text);
  font-size: var(--font-size-lg);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text-light);
  cursor: pointer;
  padding: var(--space-1);
  line-height: 1;
}

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

.modal-body {
  padding: var(--space-6);
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: calc(100vh - 200px); /* Leave room for header and footer */
}

.modal-body img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border-light);
}

.preview-unsupported,
.preview-error,
.loading {
  text-align: center;
  padding: var(--space-8);
  color: var(--color-text-light);
  position: relative;
  z-index: 1001;
}

.preview-unsupported p,
.preview-error p {
  margin: var(--space-2) 0;
}

.loading {
  font-style: italic;
}

/* Preview Button Styles */
.preview-btn {
  background: var(--color-secondary);
  color: white;
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-btn:hover {
  background: var(--color-secondary-dark);
  transform: translateY(-1px);
}
