@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --color-success: #10b981;
  --color-danger: #f43f5e;
  --color-info: #0ea5e9;
  --color-primary: #6366f1;
  --color-warning: #f59e0b;
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(14, 165, 233, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Sidebar Styling */
aside {
  width: 280px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  z-index: 100;
  transition: var(--transition);
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-info));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.brand-name h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-name p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.nav-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  font-weight: 600;
}

.salon-select-wrapper {
  margin-bottom: 2rem;
}

select.salon-dropdown {
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  box-shadow: var(--shadow);
}

select.salon-dropdown:hover, select.salon-dropdown:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.sidebar-info {
  margin-top: auto;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Main Content Area */
main {
  margin-left: 280px;
  flex: 1;
  padding: 2.5rem;
  max-width: 1600px;
  animation: fadeIn 0.6s ease-out;
}

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

.header-title h2 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

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

.date-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1.2rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-badge::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--color-success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--color-success);
}

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

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  transition: var(--transition);
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-card.kpi-revenue::after { background: var(--color-info); }
.kpi-card.kpi-cost::after { background: var(--color-danger); }
.kpi-card.kpi-ebitda::after { background: var(--color-warning); }
.kpi-card.kpi-profit::after { background: var(--color-success); }

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

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

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.kpi-subtext {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
}

.kpi-trend {
  display: flex;
  align-items: center;
  font-weight: 600;
}

.kpi-trend.positive { color: var(--color-success); }
.kpi-trend.negative { color: var(--color-danger); }
.kpi-trend.neutral { color: var(--text-secondary); }

/* Charts & Insight Layout */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-subtitle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 350px;
}

/* Insight Box (Sidebar of Charts) */
.insight-box {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.insight-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: var(--transition);
}

.insight-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Full Width Row for Table & Detailed Stats */
.full-width-row {
  margin-bottom: 2.5rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.3);
}

th {
  background: rgba(30, 41, 59, 0.9);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 500;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.font-numeric {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Special Badges */
.badge-performance {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-block;
}

.badge-star {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-turnaround {
  background: rgba(14, 165, 233, 0.15);
  color: var(--color-info);
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.badge-stable {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--color-danger);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

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

.animate-update {
  animation: pulseHighlight 0.5s ease-out;
}

@keyframes pulseHighlight {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); border-color: var(--color-primary); }
  100% { transform: scale(1); }
}

/* Responsive constraints */
@media (max-width: 1200px) {
  .dashboard-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }
  aside {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
  }
  main {
    margin-left: 0;
    padding: 1.5rem;
  }
  .brand {
    margin-bottom: 1.5rem;
  }
}

/* Print Styles for PDF Generation */
@media print {
  body {
    background: white !important;
    background-image: none !important;
    color: #000 !important;
  }
  aside, #exportPdfBtn, .salon-select-wrapper, .sidebar-info {
    display: none !important;
  }
  main {
    margin-left: 0 !important;
    padding: 1cm !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  header {
    margin-bottom: 1.5rem !important;
  }
  #dashboardTitle {
    color: #000 !important;
    font-size: 1.5rem !important;
  }
  #dashboardSubtitle {
    color: #333 !important;
    font-size: 0.85rem !important;
  }
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.5rem !important;
    margin-bottom: 1.5rem !important;
  }
  .kpi-card {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    padding: 0.75rem !important;
    box-shadow: none !important;
    border-radius: 8px !important;
    color: #000 !important;
  }
  .kpi-value {
    font-size: 1.15rem !important;
    color: #000 !important;
  }
  .kpi-trend.positive {
    color: #047857 !important;
  }
  .kpi-trend.negative {
    color: #b91c1c !important;
  }
  .kpi-subtext span {
    color: #333 !important;
  }
  .dashboard-row {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin-bottom: 1.5rem !important;
    page-break-inside: avoid;
  }
  .card {
    background: white !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    border-radius: 12px !important;
    padding: 1rem !important;
    page-break-inside: avoid;
  }
  .card-subtitle {
    color: #333 !important;
  }
  .chart-container {
    height: 220px !important;
    page-break-inside: avoid;
  }
  .insight-box {
    gap: 0.5rem !important;
  }
  .insight-item {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
    padding: 0.75rem !important;
    font-size: 0.85rem !important;
    page-break-inside: avoid;
  }
  table {
    background: white !important;
  }
  th {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border-bottom: 2px solid #cbd5e1 !important;
  }
  td {
    color: #000 !important;
    border-bottom: 1px solid #e2e8f0 !important;
  }
  .badge-performance {
    border: 1px solid #94a3b8 !important;
    color: #1e293b !important;
    background: #f1f5f9 !important;
  }
  .full-width-row {
    margin-bottom: 1.5rem !important;
    page-break-inside: avoid;
  }
}
