/* =============================================================================
   Vocal Admin — Desktop panel (EasyTrack-inspired sidebar layout)
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Variables & Theme
   ----------------------------------------------------------------------------- */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  --bg-page: #f4f5fb;
  --bg-white: #ffffff;
  --text-main: #1e1b4b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --shadow-primary-glow: 0 4px 14px rgba(99, 102, 241, 0.45);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 1rem;

  --sidebar-width: 280px;
  --header-height: 64px;
}

/* -----------------------------------------------------------------------------
   2. Base Styles
   ----------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background: var(--bg-page);
  line-height: 1.5;
}

.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-page);
}

.app-loading .loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* -----------------------------------------------------------------------------
   3. Layout
   ----------------------------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* -----------------------------------------------------------------------------
   4. Sidebar
   ----------------------------------------------------------------------------- */
.sidebar-header {
  flex-shrink: 0;
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.sidebar-header .sidebar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
}

.nav-section {
  margin-bottom: 1.25rem;
}

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

.nav-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.75rem 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-main);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-dark);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  box-shadow: var(--shadow-primary-glow);
}

.nav-item .nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

/* -----------------------------------------------------------------------------
   5. Sidebar Footer
   ----------------------------------------------------------------------------- */
.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
}

.user-details {
  min-width: 0;
  flex: 1;
}

.user-details .user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-details .user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* -----------------------------------------------------------------------------
   6. Page Header
   ----------------------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  min-height: var(--header-height);
  padding: 0.75rem 2rem;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.page-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.page-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------------------------
   7. Page Content
   ----------------------------------------------------------------------------- */
.page-content {
  flex: 1;
  padding: 1.5rem 2rem;
}

/* -----------------------------------------------------------------------------
   8. Buttons
   ----------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.125rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-primary-glow);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-main);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-light);
  color: var(--primary-dark);
}

.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #f87171;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-icon {
  padding: 0.5rem;
  min-width: 2.25rem;
  min-height: 2.25rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* -----------------------------------------------------------------------------
   9. Cards
   ----------------------------------------------------------------------------- */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.card-body {
  padding: 1.25rem;
}

/* -----------------------------------------------------------------------------
   10. Stats Grid
   ----------------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.stat-icon.blue {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
}

.stat-icon.green {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
}

.stat-icon.orange {
  background: rgba(249, 115, 22, 0.15);
  color: #ea580c;
}

.stat-icon.red {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.stat-icon.purple {
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-dark);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 0.25rem;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.02em;
}

/* -----------------------------------------------------------------------------
   11. Data Table
   ----------------------------------------------------------------------------- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-white);
}

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

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

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.data-table tr.clickable {
  cursor: pointer;
}

.data-table tr.clickable:hover {
  background: rgba(99, 102, 241, 0.08);
}

/* -----------------------------------------------------------------------------
   12. Status Badges
   ----------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1.25;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-info {
  background: #e0e7ff;
  color: var(--primary-dark);
}

.badge-gray {
  background: #f1f5f9;
  color: #475569;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-dark);
}

/* -----------------------------------------------------------------------------
   13. Forms
   ----------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* -----------------------------------------------------------------------------
   14. Modals
   ----------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  width: 100%;
  max-width: 32rem;
  max-height: min(90vh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.22s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: #fafafa;
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   15. Tabs
   ----------------------------------------------------------------------------- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #e2e8f0;
  border-radius: var(--radius-lg);
  width: fit-content;
  max-width: 100%;
}

.tab {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tab:hover:not(.active) {
  color: var(--text-main);
}

.tab.active {
  background: var(--bg-white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* -----------------------------------------------------------------------------
   16. Empty State
   ----------------------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1rem;
  opacity: 0.5;
  color: var(--primary-light);
}

.empty-state h3 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-main);
}

.empty-state p {
  margin: 0;
  font-size: 0.875rem;
  max-width: 24rem;
}

/* -----------------------------------------------------------------------------
   17. Login Split Screen
   ----------------------------------------------------------------------------- */
.login-split {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr 1fr;
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-white);
}

.login-form-side .login-form-inner {
  width: 100%;
  max-width: 400px;
}

.login-form-side .login-brand {
  margin-bottom: 2rem;
  text-align: center;
}

.login-form-side .login-brand img {
  height: 40px;
  margin-bottom: 0.5rem;
}

.login-form-side .login-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.login-form-side .login-form .form-input {
  margin-top: 0.25rem;
}

.login-visual-side {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  overflow: hidden;
  background: var(--gradient);
}

.login-visual-side::before,
.login-visual-side::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

/* Radial overlays — purple/violet (Vocal), not blue */
.login-visual-side::before {
  width: 120%;
  height: 120%;
  top: -30%;
  right: -20%;
  background: radial-gradient(circle at 70% 30%, rgba(255, 255, 255, 0.18) 0%, transparent 45%);
}

.login-visual-side::after {
  width: 80%;
  height: 80%;
  bottom: -25%;
  left: -15%;
  background: radial-gradient(circle at 30% 70%, rgba(118, 75, 162, 0.5) 0%, transparent 50%);
}

.login-visual-content {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #fff;
  max-width: 28rem;
}

.login-visual-content h2 {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
}

.login-visual-content p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.92;
  line-height: 1.6;
}

.login-form-side .form-code-input,
.form-code-input {
  display: block;
  width: 100%;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
  padding: 1rem 1.25rem;
  font-size: 1.75rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.35em;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-code-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* -----------------------------------------------------------------------------
   18. Animations
   ----------------------------------------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* -----------------------------------------------------------------------------
   19. Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-header {
    display: flex !important;
  }

  .page-header {
    padding: 0.75rem 1rem;
  }

  .page-content {
    padding: 1rem;
  }

  .login-split {
    grid-template-columns: 1fr;
  }

  .login-visual-side {
    min-height: 200px;
    order: -1;
  }
}

/* -----------------------------------------------------------------------------
   20. Scrollbar
   ----------------------------------------------------------------------------- */
.sidebar-nav::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar-nav::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* -----------------------------------------------------------------------------
   21. Utilities
   ----------------------------------------------------------------------------- */
.text-primary {
  color: var(--primary);
}

.text-success {
  color: #16a34a;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-1 {
  gap: 0.25rem;
}
.gap-2 {
  gap: 0.5rem;
}
.gap-3 {
  gap: 0.75rem;
}
.gap-4 {
  gap: 1rem;
}
.gap-6 {
  gap: 1.5rem;
}

.hidden {
  display: none !important;
}
