/* ============================
   CSS Variables & Reset
   ============================ */
:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-bg-dark: #16213e;
  --sidebar-width: 260px;
  --content-bg: #f0f2f5;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --success-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #d1d5db;
  --border-light: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
  --transition: 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--content-bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================
   View System
   ============================ */
.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

/* ============================
   Auth View
   ============================ */
#auth-view {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, var(--sidebar-bg-dark) 50%, #0f3460 100%);
}

#auth-view.active {
  display: flex;
}

.auth-container {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.auth-logo {
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  letter-spacing: -0.5px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 12px 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Auth Forms */
.auth-form {
  animation: fadeIn 0.3s ease;
}

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

/* ============================
   Main App Layout
   ============================ */
#main-app {
  display: flex;
  min-height: 100vh;
}

/* ============================
   Sidebar
   ============================ */
#sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-dark) 100%);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header h2 {
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

#sidebar nav {
  flex: 1;
  padding: 16px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.nav-link:hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--primary);
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#user-name {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 100%;
  text-align: center;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ============================
   Content Area
   ============================ */
#content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  min-height: 100vh;
}

/* ============================
   Page Header
   ============================ */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* ============================
   Cards
   ============================ */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  display: block;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.card-subtitle {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============================
   Buttons
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: var(--success-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-block {
  width: 100%;
}

/* ============================
   Forms
   ============================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group input::placeholder,
input::placeholder {
  color: #9ca3af;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-top: 12px;
}

.form-row input {
  flex: 1;
}

.form-row .btn {
  flex-shrink: 0;
}

/* ============================
   Tables
   ============================ */
.table-wrapper {
  overflow-x: auto;
  margin-top: 12px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-light);
  background: #fafbfc;
}

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

.table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.table tbody tr:hover {
  background: #f0f4ff;
}

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

/* ============================
   Notifications
   ============================ */
#notification-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notification-item {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition);
}

.notification-item:hover {
  box-shadow: var(--shadow-md);
}

.notification-item .notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notification-item .notification-message {
  font-size: 0.9rem;
  color: var(--text);
}

.notification-item .notification-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  color: #ffffff;
}

.badge-email {
  background: var(--primary);
}

.badge-sms {
  background: #8b5cf6;
}

.badge-push {
  background: #f59e0b;
}

.badge-admin {
  background: var(--danger);
}

.badge-user {
  background: var(--success);
}

/* ============================
   Toast Notifications
   ============================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastSlideIn 0.35s ease forwards;
  max-width: 380px;
  line-height: 1.4;
}

.toast.removing {
  animation: toastSlideOut 0.3s ease forwards;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

.toast-info {
  background: var(--primary);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ============================
   Create Account Button
   ============================ */
#create-account-btn {
  margin-bottom: 24px;
  padding: 14px 28px;
  font-size: 1rem;
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 768px) {
  #sidebar {
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
  }

  #sidebar.open {
    width: var(--sidebar-width);
  }

  #content {
    margin-left: 0;
    padding: 24px 16px;
  }

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

  .auth-container {
    margin: 20px;
    padding: 28px 24px;
  }

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

  .form-row input {
    width: 100%;
  }
}

/* ============================
   Scrollbar Styling
   ============================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c1c9d4;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0aab5;
}

/* ============================
   Selection
   ============================ */
::selection {
  background: rgba(59, 130, 246, 0.2);
  color: var(--text);
}
