/* ==========================================================================
   ViViD Admin Portal - Premium Styling
   ========================================================================== */

:root {
  /* Colors */
  --bg-dark: #050508;
  --bg-panel: rgba(0, 0, 0, 0.4);
  --bg-panel-hover: rgba(0, 0, 0, 0.2);
  --bg-input: rgba(0, 0, 0, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.15);
  
  --primary: #f97316; /* Orange 500 */
  --primary-hover: #ea580c; /* Orange 600 */
  --secondary: #4b5563;
  --secondary-hover: #374151;
  --accent: #fbbf24; /* Amber 400 */
  
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-accent: #fbbf24;
  --error: #ef4444;
  --success: #f97316;
  --warning: #f59e0b;
  
  /* Typography */
  --font-sans: 'Inter', system-ui, sans-serif;
  
  /* Shadows & Effects */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --blur-md: blur(12px);
  --blur-lg: blur(24px);
  
  /* Layout */
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: color-mix(in srgb, #080112 40%, #140105 60%);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   Utilities & Glassmorphism
   ========================================================================== */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.glass-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.glass-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

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

select.glass-input {
  appearance: none;
  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='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.btn-secondary {
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-panel-hover);
  border-color: var(--glass-highlight);
}

.btn-block {
  width: 100%;
}

.btn-google {
  background: white;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
}

.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
  transform: translateY(-1px);
}

.google-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

/* ==========================================================================
   Auth Screen
   ========================================================================== */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  text-align: center;
}

.logo img {
  height: 48px;
  margin-bottom: 1rem;
}

.logo h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.form-group {
  text-align: left;
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.error-text {
  color: var(--error);
  font-size: 0.875rem;
  margin-top: 1rem;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.75rem;
  border-radius: 8px;
}

/* ==========================================================================
   Dashboard Layout
   ========================================================================== */
.dashboard-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: none;
  border-top: none;
  border-bottom: none;
  z-index: 40;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-logo {
  height: 32px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}

.nav-item:hover {
  background: var(--bg-panel-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(249, 115, 22, 0.15);
  color: var(--primary);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--glass-border);
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

.admin-profile .info {
  display: flex;
  flex-direction: column;
}

.admin-profile .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.admin-profile .logout {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  text-align: left;
  margin-top: 0.1rem;
}

.admin-profile .logout:hover {
  color: var(--error);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2.5rem 2.5rem 2.5rem;
}

.view-section {
  animation: fadeIn 0.4s ease-out;
}

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

.section-header {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-header p {
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  align-items: center;
}

.search-input {
  max-width: 300px;
}

/* ==========================================================================
   Metrics Grid
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.metric-card {
  padding: 1.5rem;
}

.metric-card h4 {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.metric-card .value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}

.text-success { color: var(--success); }

/* ==========================================================================
   Charts Grid
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
}

.chart-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chart-container {
  flex-grow: 1;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-container {
  overflow-x: auto;
  padding: 1px; /* for border */
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
}

.data-table th:first-child { border-top-left-radius: 15px; }
.data-table th:last-child { border-top-right-radius: 15px; }

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

.data-table tbody tr:hover {
  background: var(--bg-panel-hover);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.admin { background: rgba(251, 191, 36, 0.2); color: #fcd34d; border: 1px solid rgba(251, 191, 36, 0.3); }
.badge.user { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

.badge.Free { background: rgba(148, 163, 184, 0.1); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.2); }
.badge.Trial { background: rgba(56, 189, 248, 0.2); color: #7dd3fc; border: 1px solid rgba(56, 189, 248, 0.3); }
.badge.Basic { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.Pro { background: rgba(249, 115, 22, 0.2); color: #fcd34d; border: 1px solid rgba(249, 115, 22, 0.3); }
.badge.Ultra { background: rgba(236, 72, 153, 0.2); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.badge.Custom { background: rgba(139, 92, 246, 0.2); color: #a78bfa; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge.Enterprise { background: rgba(249, 115, 22, 0.2); color: #fcd34d; border: 1px solid rgba(249, 115, 22, 0.3); }

.action-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.action-btn:hover {
  background: rgba(249, 115, 22, 0.1);
}

/* ==========================================================================
   Action Grid
   ========================================================================== */
.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
}

.action-card {
  padding: 2rem;
}

.action-card h3 {
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  width: 100%;
  max-width: 450px;
  padding: 2rem;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background: rgba(15, 23, 42, 0.95) !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2rem;
}

/* ==========================================================================
   Loaders
   ========================================================================== */
.glass-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.3s;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

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

/* ==========================================================================
   Invoice Generator
   ========================================================================== */
.template-card:hover, .receipt-template-card:hover, .order-template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(249, 115, 22, 0.2);
  border-color: var(--primary) !important;
}
.template-card.selected, .receipt-template-card.selected, .order-template-card.selected {
  border-color: var(--primary) !important;
  background: rgba(249, 115, 22, 0.1);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Mobile Responsiveness (Media Queries)
   ========================================================================== */
@media (max-width: 768px) {
  .dashboard-layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem;
  }
  .sidebar-header {
    padding: 0.5rem 0;
    justify-content: center;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 0.5rem 0;
    gap: 0.5rem;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-group-card {
    display: contents;
  }
  .sidebar-group-card .group-header, .group-section-title {
    display: none !important;
  }
  .nav-item {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    width: auto;
    display: inline-flex;
    gap: 0.5rem;
  }
  .sidebar-footer {
    border-top: none;
    padding: 0.5rem 0;
  }
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
  .action-grid {
    grid-template-columns: 1fr;
  }
  .top-action-bar {
    padding: 0;
    margin-bottom: 1rem;
  }
}

/* ==========================================================================
   Sidebar Card Colors
   ========================================================================== */
.sidebar-group-card {
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.sidebar-group-card.overview-card {
  border-color: rgba(14, 165, 233, 0.3) !important;
  background: rgba(14, 165, 233, 0.06) !important;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.1);
}
.sidebar-group-card.overview-card .nav-item {
  color: rgba(56, 189, 248, 0.8) !important;
}
.sidebar-group-card.overview-card .nav-item:hover {
  background: rgba(14, 165, 233, 0.15) !important;
  color: #fff !important;
}
.sidebar-group-card.overview-card .nav-item.active {
  background: rgba(14, 165, 233, 0.25) !important;
  color: #fff !important;
  border: 1px solid rgba(14, 165, 233, 0.4) !important;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.2);
}

.sidebar-group-card.business-card {
  border-color: rgba(249, 115, 22, 0.3) !important;
  background: rgba(249, 115, 22, 0.06) !important;
  box-shadow: 0 4px 15px rgba(249, 115, 22, 0.1);
}
.sidebar-group-card.business-card .nav-item {
  color: rgba(251, 146, 60, 0.8) !important;
}
.sidebar-group-card.business-card .nav-item:hover {
  background: rgba(249, 115, 22, 0.15) !important;
  color: #fff !important;
}
.sidebar-group-card.business-card .nav-item.active {
  background: rgba(249, 115, 22, 0.25) !important;
  color: #fff !important;
  border: 1px solid rgba(249, 115, 22, 0.4) !important;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.2);
}

.sidebar-group-card.finance-card {
  border-color: rgba(16, 185, 129, 0.3) !important;
  background: rgba(16, 185, 129, 0.06) !important;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}
.sidebar-group-card.finance-card .nav-item {
  color: rgba(52, 211, 153, 0.8) !important;
}
.sidebar-group-card.finance-card .nav-item:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #fff !important;
}
.sidebar-group-card.finance-card .nav-item.active {
  background: rgba(16, 185, 129, 0.25) !important;
  color: #fff !important;
  border: 1px solid rgba(16, 185, 129, 0.4) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.sidebar-group-card.maintenance-card {
  border-color: rgba(244, 63, 94, 0.3) !important;
  background: rgba(244, 63, 94, 0.06) !important;
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.1);
}
.sidebar-group-card.maintenance-card .nav-item {
  color: rgba(251, 113, 133, 0.8) !important;
}
.sidebar-group-card.maintenance-card .nav-item:hover {
  background: rgba(244, 63, 94, 0.15) !important;
  color: #fff !important;
}
.sidebar-group-card.maintenance-card .nav-item.active {
  background: rgba(244, 63, 94, 0.25) !important;
  color: #fff !important;
  border: 1px solid rgba(244, 63, 94, 0.4) !important;
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.2);
}
