/* ==========================================================================
   META ADS REPORT DASHBOARD - DESIGN SYSTEM & STYLES
   Aesthetics: Modern Glassmorphism, Dark/Light HSL Palettes, Meta Gradients
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(0, 130, 251, 0.4);
  
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-dark: #374151;

  --meta-blue: #0064E0;
  --meta-cyan: #00C6FF;
  --meta-purple: #8B5CF6;
  --meta-emerald: #10B981;
  --meta-amber: #F59E0B;
  --meta-rose: #EF4444;

  --grad-primary: linear-gradient(135deg, #0064E0 0%, #0082FB 50%, #00C6FF 100%);
  --grad-purple: linear-gradient(135deg, #7C3AED 0%, #C084FC 100%);
  --grad-emerald: linear-gradient(135deg, #059669 0%, #34D399 100%);
  --grad-amber: linear-gradient(135deg, #D97706 0%, #FBBF24 100%);
  --grad-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-glow: 0 0 25px rgba(0, 130, 251, 0.25);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RESET & BASE */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(0, 100, 224, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
}

/* UTILITY CLASSES */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1.25rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1.25rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* GLASS CARD STYLING */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

/* LOGIN OVERLAY */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.login-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.login-box {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(0, 130, 251, 0.3);
  box-shadow: var(--shadow-glow);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.meta-logo {
  display: inline-flex;
  margin-bottom: 1rem;
  filter: drop-shadow(0 0 12px rgba(0, 130, 251, 0.5));
}

.login-header h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* FORM ELEMENTS */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.input-wrapper input,
.form-group input,
.custom-select {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.75rem;
  background: rgba(17, 24, 39, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-group input:not(.input-wrapper input) {
  padding-left: 1rem;
}

.custom-select {
  padding-left: 1rem;
  cursor: pointer;
}

.input-wrapper input:focus,
.form-group input:focus,
.custom-select:focus {
  outline: none;
  border-color: var(--meta-blue);
  box-shadow: 0 0 0 3px rgba(0, 100, 224, 0.25);
}

.btn-toggle-pass {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.input-with-gen {
  display: flex;
  gap: 0.5rem;
}

.input-with-gen input {
  flex: 1;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 100, 224, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 100, 224, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--meta-rose);
  color: var(--meta-rose);
}

.btn-block { width: 100%; }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

.demo-acc-hint {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-color);
}

.hint-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.hint-badge-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hint-badge {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}

.hint-badge:hover {
  border-color: var(--meta-cyan);
  background: rgba(0, 198, 255, 0.1);
}

.hint-badge code {
  color: var(--meta-cyan);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.alert-box {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert-box.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

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

/* SIDEBAR */
.sidebar {
  width: 270px;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.3px;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--meta-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin: 1.25rem 0 0.5rem 0.75rem;
}

.nav-section-title:first-child {
  margin-top: 0;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0.25rem;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 100, 224, 0.3);
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.5);
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-role-badge {
  font-size: 0.7rem;
  color: var(--meta-cyan);
}

/* MAIN CONTENT AREA */
.main-content {
  margin-left: 270px;
  flex: 1;
  padding: 2rem;
  max-width: 1600px;
}

/* TOP HEADER */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.header-title-area h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-title-area p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

/* KPI GRID */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
}

.kpi-card {
  padding: 1.35rem;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--border-color);
}

.kpi-card.accent-blue::before { background: var(--grad-primary); }
.kpi-card.accent-emerald::before { background: var(--grad-emerald); }
.kpi-card.accent-purple::before { background: var(--grad-purple); }
.kpi-card.accent-amber::before { background: var(--grad-amber); }

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-icon {
  font-size: 1.25rem;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.4rem;
}

.kpi-foot {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.kpi-foot.positive { color: var(--meta-emerald); }
.kpi-sub { font-size: 0.78rem; color: var(--text-muted); }

/* CHARTS GRID */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

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

.chart-card.span-2 {
  grid-column: span 2;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 300px;
}

/* DATA TABLES */
.table-toolbar {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 300px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-responsive {
  overflow-x: auto;
}

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

.data-table th {
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

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

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success { background: rgba(16, 185, 129, 0.18); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info { background: rgba(0, 198, 255, 0.18); color: #38bdf8; border: 1px solid rgba(0, 198, 255, 0.3); }
.badge-purple { background: rgba(139, 92, 246, 0.18); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }

/* FUNNEL CONTAINER */
.funnel-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

.funnel-step {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.funnel-label {
  width: 180px;
  font-weight: 700;
  font-size: 0.9rem;
}

.funnel-bar-wrapper {
  flex: 1;
  height: 42px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.funnel-bar-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding-left: 1rem;
  font-weight: 700;
  color: #fff;
  font-size: 0.88rem;
  transition: width 0.6s ease;
}

.funnel-conversion {
  width: 110px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--meta-cyan);
}

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

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

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.file-drop-area {
  border: 2px dashed var(--border-highlight);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: rgba(0, 100, 224, 0.03);
  cursor: pointer;
  transition: var(--transition);
}

.file-drop-area:hover {
  background: rgba(0, 100, 224, 0.08);
  border-color: var(--meta-cyan);
}

.link-label {
  color: var(--meta-cyan);
  text-decoration: underline;
  cursor: pointer;
}

.hidden-file-input { display: none; }

.selected-file-name {
  margin-top: 0.75rem;
  font-weight: 700;
  color: var(--meta-emerald);
  font-size: 0.85rem;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  background: var(--bg-secondary);
  border: 1px solid var(--meta-cyan);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.88rem;
  animation: slideUp 0.3s ease;
}

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

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  .main-content { margin-left: 220px; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card.span-2 { grid-column: span 1; }
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; position: relative; height: auto; border-right: none; border-bottom: 1px solid var(--border-color); }
  .main-content { margin-left: 0; padding: 1rem; }
  .top-header { flex-direction: column; align-items: flex-start; }
}
