/* ===============================
   ANALISIS DASHBOARD - Responsive Mobile Optimized (95% Scale)
   =============================== */

.analisis-container {
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  padding: 50px;
  transform: scale(0.95);
  transform-origin: top center;
  background-color: #f8fbfd;
  transition: background-color 0.3s ease;
}

body.dark .analisis-container {
  background-color: #1a1a1a;
  color: #66b3ff;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: #004d9d;
  margin-bottom: 14px;
}

body.dark .page-title {
  color: #66b3ff;
}

/* Sales Section */
.sales-section {
  background: white;
  border-radius: 9px;
  padding: 19px;
  margin-bottom: 19px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

body.dark .sales-section {
  background: #2a2a2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 4px;
}

body.dark .section-header h2 {
  color: #66b3ff;
}

.subtitle {
  color: #888;
  font-size: 12px;
  margin-bottom: 15px;
}

body.dark .subtitle {
  color: #aaa;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 15px;
}

.stat-card {
  padding: 15px;
  border-radius: 8px;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.stat-card.pink {
  background: linear-gradient(135deg, #ffe5f0 0%, #ffd6e8 100%);
}

.stat-card.yellow {
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
}

.stat-card.green {
  background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
}

.stat-card.purple {
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
}

body.dark .stat-card {
  opacity: 0.9;
}

/* Stat Icon */
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 11px;
  font-size: 15px;
}

.stat-card.pink .stat-icon {
  background: #ff4081;
  color: white;
}

.stat-card.yellow .stat-icon {
  background: #ff9800;
  color: white;
}

.stat-card.green .stat-icon {
  background: #4caf50;
  color: white;
}

.stat-card.purple .stat-icon {
  background: #9c27b0;
  color: white;
}

/* Stat Values */
.stat-value {
  font-size: 19px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
  line-height: 1.2;
}

body.dark .stat-value {
  color: #66b3ff;
}

.stat-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
  line-height: 1.3;
}

body.dark .stat-label {
  color: #aaa;
}

.stat-change {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
}

.stat-change.positive {
  color: #4caf50;
}

.stat-change.negative {
  color: #f44336;
}

/* Dashboard Grid for Charts */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 19px;
  margin-bottom: 19px;
}

/* Chart Cards */
.chart-card {
  background: white;
  border-radius: 9px;
  padding: 19px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

body.dark .chart-card {
  background: #2a2a2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.chart-card h2 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 15px;
}

body.dark .chart-card h2 {
  color: #66b3ff;
}

.chart-container {
  height: 250px;
  margin-bottom: 15px;
  position: relative;
  overflow: hidden;
}

/* Chart Legend */
.chart-legend {
  display: flex;
  justify-content: center;
  padding-top: 11px;
  border-top: 1px solid #eee;
}

body.dark .chart-legend {
  border-top-color: #444;
}

.legend-label {
  font-size: 12px;
  color: #666;
}

body.dark .legend-label {
  color: #aaa;
}

/* Chart Legends (Multiple) */
.chart-legends {
  display: flex;
  gap: 22px;
  padding-top: 11px;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
}

body.dark .chart-legends {
  border-top-color: #444;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend-color.green {
  background: #4caf50;
}

.legend-color.yellow {
  background: #ffc107;
}

.legend-text {
  color: #666;
}

body.dark .legend-text {
  color: #aaa;
}

.legend-value {
  color: #1a1a1a;
  font-weight: 600;
  margin-left: auto;
}

body.dark .legend-value {
  color: #66b3ff;
}

/* Top Services Table */
.table-card {
  background: white;
  border-radius: 9px;
  padding: 19px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

body.dark .table-card {
  background: #2a2a2a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.table-card h2 {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 15px;
}

body.dark .table-card h2 {
  color: #66b3ff;
}

/* Table Styles */
.services-table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
}

.services-table thead {
  background: #f8f9fa;
}

body.dark .services-table thead {
  background: #333;
}

.services-table th {
  padding: 10px 11px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  border-bottom: 2px solid #eee;
}

body.dark .services-table th {
  color: #aaa;
  border-bottom-color: #444;
}

.services-table th:first-child {
  border-top-left-radius: 6px;
}

.services-table th:last-child {
  border-top-right-radius: 6px;
}

.services-table td {
  padding: 11px;
  font-size: 12px;
  color: #1a1a1a;
  border-bottom: 1px solid #eee;
}

body.dark .services-table td {
  color: #e8e8e8;
  border-bottom-color: #444;
}

.services-table tbody tr {
  transition: background-color 0.2s ease;
}

.services-table tbody tr:hover {
  background: #f8f9fa;
}

body.dark .services-table tbody tr:hover {
  background: #3a3a3a;
}

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

/* Service Type Label */
.service-type {
  font-weight: 600;
  margin-left: 2px;
}

/* Popularity Bar */
.popularity-bar {
  width: 100%;
  max-width: 170px;
  height: 7px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

body.dark .popularity-bar {
  background: #444;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-fill.red {
  background: linear-gradient(90deg, #ff5252 0%, #f44336 100%);
}

.progress-fill.orange {
  background: linear-gradient(90deg, #ffb74d 0%, #ff9800 100%);
}

.progress-fill.green {
  background: linear-gradient(90deg, #66bb6a 0%, #4caf50 100%);
}

.progress-fill.purple {
  background: linear-gradient(90deg, #ba68c8 0%, #9c27b0 100%);
}

/* Badges */
.badge {
  padding: 4px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  display: inline-block;
}

.badge.red {
  background: #f44336;
}

.badge.orange {
  background: #ff9800;
}

.badge.green {
  background: #4caf50;
}

.badge.purple {
  background: #9c27b0;
}

/* =========================================================
   RESPONSIVE DESIGN - MOBILE OPTIMIZED
========================================================= */

/* Tablet (1024px) */
@media screen and (max-width: 1024px) {
  .analisis-container {
    transform: scale(1);
    padding: 20px 25px;
  }

  .page-title {
    font-size: 22px;
  }

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

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
  }
}

/* Tablet Small & Mobile Large (768px) */
@media screen and (max-width: 768px) {
  .analisis-container {
    transform: scale(1);
    padding: 20px;
  }

  .page-title {
    font-size: 20px;
    margin-bottom: 16px;
  }

  .sales-section {
    padding: 18px;
    margin-bottom: 18px;
  }

  .section-header h2 {
    font-size: 18px;
  }

  .subtitle {
    font-size: 13px;
  }

  /* Stats Grid - 2 columns on tablet */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-change {
    font-size: 10px;
  }

  /* Charts */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 18px;
    margin-bottom: 18px;
  }

  .chart-card {
    padding: 18px;
  }

  .chart-card h2 {
    font-size: 17px;
  }

  .chart-container {
    height: 160px;
  }

  .chart-legends {
    gap: 15px;
  }

  /* Table */
  .table-card {
    padding: 18px;
    overflow-x: auto;
  }

  .table-card h2 {
    font-size: 17px;
  }

  .services-table {
    font-size: 12px;
    min-width: 600px;
  }

  .services-table th,
  .services-table td {
    padding: 10px;
  }

  .popularity-bar {
    max-width: 140px;
  }
}

/* Mobile Medium (480px - 640px) */
@media screen and (max-width: 640px) {
  .analisis-container {
    padding: 16px;
  }

  .page-title {
    font-size: 19px;
  }

  .sales-section {
    padding: 16px;
  }

  .section-header h2,
  .chart-card h2,
  .table-card h2 {
    font-size: 16px;
  }

  /* Stats - Still 2 columns but smaller */
  .stats-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-icon {
    width: 30px;
    height: 30px;
    font-size: 13px;
    margin-bottom: 8px;
  }

  .stat-value {
    font-size: 15px;
  }

  .stat-label {
    font-size: 10px;
    margin-bottom: 4px;
  }

  .stat-change {
    font-size: 9px;
  }

  /* Charts */
  .chart-card {
    padding: 16px;
  }

  .chart-container {
    height: 180px;
  }

  .chart-legends {
    flex-direction: column;
    gap: 10px;
  }

  .legend-item {
    font-size: 11px;
  }

  /* Table */
  .table-card {
    padding: 16px;
  }

  .services-table {
    font-size: 11px;
  }

  .services-table th,
  .services-table td {
    padding: 8px;
  }
}

/* Mobile Small (< 480px) */
@media screen and (max-width: 480px) {
  .analisis-container {
    padding: 14px 12px;
  }

  .page-title {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .sales-section,
  .chart-card,
  .table-card {
    padding: 14px;
    margin-bottom: 14px;
    border-radius: 8px;
  }

  .section-header h2,
  .chart-card h2,
  .table-card h2 {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .subtitle {
    font-size: 12px;
  }

  /* Stats Grid - Change to 1 column on small mobile */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .stat-content {
    flex: 1;
  }

  .stat-value {
    font-size: 16px;
    margin-bottom: 2px;
  }

  .stat-label {
    font-size: 10px;
    margin-bottom: 3px;
  }

  .stat-change {
    font-size: 9px;
  }

  /* Charts */
  .dashboard-grid {
    gap: 14px;
    margin-bottom: 14px;
  }

  .chart-container {
    height: 160px;
    margin-bottom: 12px;
  }

  .chart-legend,
  .chart-legends {
    padding-top: 10px;
  }

  .legend-item {
    font-size: 11px;
    gap: 5px;
  }

  .legend-color {
    width: 8px;
    height: 8px;
  }

  /* Table - Full horizontal scroll */
  .table-card {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .services-table {
    min-width: 550px;
    font-size: 11px;
  }

  .services-table th {
    padding: 8px 6px;
    font-size: 10px;
  }

  .services-table td {
    padding: 9px 6px;
    font-size: 11px;
  }

  .popularity-bar {
    max-width: 100px;
    height: 6px;
  }

  .badge {
    padding: 3px 8px;
    font-size: 10px;
  }
}

/* Mobile Extra Small (< 375px) */
@media screen and (max-width: 374px) {
  .analisis-container {
    padding: 12px 10px;
  }

  .page-title {
    font-size: 17px;
  }

  .sales-section,
  .chart-card,
  .table-card {
    padding: 12px;
  }

  .section-header h2,
  .chart-card h2,
  .table-card h2 {
    font-size: 14px;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .stat-value {
    font-size: 15px;
  }

  .stat-label {
    font-size: 9px;
  }

  .stat-change {
    font-size: 8px;
  }

  .chart-container {
    height: 150px;
  }

  .services-table {
    min-width: 520px;
  }
}

/* Landscape Mode untuk Mobile */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .analisis-container {
    padding: 15px 20px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
    margin-bottom: 6px;
  }

  .stat-value {
    font-size: 16px;
  }

  .stat-label {
    font-size: 10px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }

  .chart-container {
    height: 200px;
  }
}

/* Touch Optimization */
@media (max-width: 768px) {
  /* Better touch targets */
  .stat-card {
    min-height: 80px;
  }

  /* Smooth scrolling for tables */
  .table-card {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .table-card::-webkit-scrollbar {
    height: 6px;
  }

  .table-card::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
  }

  body.dark .table-card::-webkit-scrollbar-track {
    background: #333;
  }

  .table-card::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
  }

  .table-card::-webkit-scrollbar-thumb:hover {
    background: #555;
  }

  /* Prevent text selection on double tap */
  .stat-card,
  .chart-card,
  .table-card {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  /* Allow text selection in table */
  .services-table {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* =========================================================
   SMOOTH TRANSITIONS
========================================================= */
* {
  transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

button,
a,
input:focus,
select:focus {
  transition: background-color 0.25s ease, color 0.25s ease,
    border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease !important;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
