/**
 * RedMail Pro - Main Styles
 * Dark theme with glassmorphism
 */

/* ===================================
   RESET & BASE
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --color-bg-primary: #000000;
  --color-bg-secondary: #0a0a0a;
  --color-bg-tertiary: #1a1a1a;
  --color-accent-primary: #e53e3e;
  --color-accent-secondary: #c53030;
  --color-accent-light: #fc8181;
  --color-text-primary: #ffffff;
  --color-text-secondary: #a0aec0;
  --color-text-tertiary: #cbd5e0;
  --color-success: #48bb78;
  --color-warning: #ed8936;
  --color-error: #fc8181;

  /* Glass effects */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-blur: blur(10px);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Fira Code', 'Courier New', monospace;
}

body {
  font-family: var(--font-primary);
  background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===================================
   APP LAYOUT
   =================================== */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  z-index: 100;
}

.main-wrapper {
  display: flex;
  margin-top: 70px;
  min-height: calc(100vh - 70px - 60px);
}

.app-sidebar {
  position: fixed;
  left: 0;
  top: 70px;
  width: 280px;
  height: calc(100vh - 70px - 60px);
  overflow-y: auto;
  z-index: 50;
}

.main-content {
  margin-left: 280px;
  flex: 1;
  padding: var(--spacing-lg);
  width: calc(100% - 280px);
}

.app-footer {
  margin-left: 280px;
  height: 60px;
  margin-top: auto;
}

/* ===================================
   HEADER
   =================================== */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 var(--spacing-lg);
}

.app-logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-text {
  color: var(--color-text-primary);
}

.logo-accent {
  color: var(--color-accent-primary);
  text-shadow: 0 0 20px rgba(229, 62, 62, 0.5);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.user-info {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* ===================================
   SIDEBAR
   =================================== */
.sidebar-nav {
  padding: var(--spacing-md);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: 8px;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 500;
}

.nav-item svg {
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--color-text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  color: var(--color-accent-primary);
  background: rgba(229, 62, 62, 0.1);
  border-left: 3px solid var(--color-accent-primary);
}

/* ===================================
   FOOTER
   =================================== */
.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 var(--spacing-lg);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

/* ===================================
   AUTH PAGES
   =================================== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--spacing-lg);
  background: radial-gradient(circle at top right, #1a1a1a, #000000);
}

.auth-container {
  width: 100%;
  max-width: 500px;
}

.auth-card {
  padding: var(--spacing-xl);
}

.auth-header {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.auth-logo {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-sm);
}

.auth-subtitle {
  color: var(--color-text-secondary);
  font-size: 1.1rem;
}

.auth-form {
  margin-top: var(--spacing-lg);
}

.auth-footer {
  text-align: center;
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--glass-border);
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* ===================================
   FORMS
   =================================== */
.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
  color: var(--color-text-primary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
}

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

.form-actions {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-lg);
}

/* ===================================
   PAGE ELEMENTS
   =================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 700;
}

/* ===================================
   ALERTS
   =================================== */
.alert {
  padding: var(--spacing-md);
  border-radius: 8px;
  margin-bottom: var(--spacing-md);
}

.alert-error {
  background: rgba(252, 129, 129, 0.1);
  border: 1px solid rgba(252, 129, 129, 0.3);
  color: var(--color-error);
}

.alert-success {
  background: rgba(72, 187, 120, 0.1);
  border: 1px solid rgba(72, 187, 120, 0.3);
  color: var(--color-success);
}

.alert-warning {
  background: rgba(237, 137, 54, 0.1);
  border: 1px solid rgba(237, 137, 54, 0.3);
  color: var(--color-warning);
}

/* ===================================
   TABLES
   =================================== */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: var(--spacing-sm) var(--spacing-md);
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--glass-border);
}

td {
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tr:hover td {
  background: var(--glass-bg-hover);
}

/* ===================================
   STATS GRID
   =================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.stat-card {
  padding: var(--spacing-lg);
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-accent-primary);
  text-shadow: 0 0 20px rgba(229, 62, 62, 0.5);
  margin-bottom: var(--spacing-xs);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===================================
   ERROR PAGES
   =================================== */
.error-card {
  text-align: center;
  padding: var(--spacing-xl);
}

.error-icon {
  margin-bottom: var(--spacing-lg);
  color: var(--color-accent-primary);
  opacity: 0.8;
}

.error-icon svg {
  filter: drop-shadow(0 0 20px rgba(229, 62, 62, 0.5));
}

.error-title {
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-accent-primary);
  margin-bottom: var(--spacing-sm);
}

.error-message {
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  margin-bottom: var(--spacing-lg);
}

.error-actions {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
  margin-top: var(--spacing-lg);
}

.error-details {
  margin-top: var(--spacing-lg);
  text-align: left;
}

.error-details summary {
  cursor: pointer;
  padding: var(--spacing-sm);
  color: var(--color-text-secondary);
}

.error-details pre {
  margin-top: var(--spacing-sm);
  padding: var(--spacing-md);
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ===================================
   MOBILE MENU TOGGLE
   =================================== */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  padding: 8px;
  margin-right: var(--spacing-sm);
  border-radius: 6px;
  transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-toggle svg {
  display: block;
}

/* Mobile overlay */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 40;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-overlay.active {
  opacity: 1;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 1024px) {
  .mobile-menu-toggle {
    display: block;
  }

  .header-left {
    display: flex;
    align-items: center;
  }

  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
  }

  .app-sidebar.active {
    transform: translateX(0);
  }

  .main-content,
  .app-footer {
    margin-left: 0;
    width: 100%;
  }

  /* Show overlay when sidebar is active */
  body:has(.app-sidebar.active) .mobile-overlay {
    display: block;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: var(--spacing-sm);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

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

  /* Header adjustments */
  .header-content {
    padding: 0 var(--spacing-sm);
  }

  .app-logo {
    font-size: 1.25rem;
  }

  .user-info {
    display: none;
  }

  .logout-text {
    display: none;
  }

  /* Table wrapper for horizontal scroll */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .glass-table {
    min-width: 600px;
  }

  /* Form actions stack on mobile */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn-glass {
    width: 100%;
  }

  /* Auth page adjustments */
  .auth-page {
    padding: var(--spacing-sm);
  }

  .auth-card {
    padding: var(--spacing-md);
  }
}

@media (max-width: 480px) {
  .app-logo {
    font-size: 1.1rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .btn-glass {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .glass-table {
    font-size: 0.85rem;
  }

  th, td {
    padding: var(--spacing-xs) var(--spacing-sm);
  }
}
