/* ================================
   Apple-Style, iOS-Native Dashboard
   ================================ */

/* --- 1. Reset & Base Styles --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at 60% 0%, #23395e 0%, #181f2f 100%);
  color: #e1e5eb;
  min-height: 100vh;
  letter-spacing: 0.01em;
  transition: background 0.35s cubic-bezier(.6,.2,.1,1);
}

/* --- 2. Layout Containers --- */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* --- 3. Sidebar --- */
.sidebar {
  background: rgba(19, 26, 36, 0.92);
  width: 72px;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 2.2rem;
  box-shadow: 4px 0 32px 0 #0008;
  border-top-right-radius: 18px;
  border-bottom-right-radius: 18px;
  backdrop-filter: blur(12px);
  z-index: 10;
  transition: box-shadow 0.22s, background 0.25s;
}

.logo {
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 2.3rem;
  text-shadow: 0 3px 22px #00b7ff99;
  filter: drop-shadow(0 1px 6px #00b7ff88);
  padding-left: 14px; /* Add this line */
}


.nav {
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.nav-item {
  font-size: 1.45rem;
  color: #cbe3fa;
  opacity: 0.87;
  text-decoration: none;
  transition: color 0.18s, opacity 0.2s, transform 0.16s;
  padding: 10px 0;
  border-radius: 14px;
}
.nav-item.active,
.nav-item:hover,
.nav-item:focus-visible {
  color: #00b7ff;
  background: rgba(0,183,255,0.06);
  opacity: 1;
  transform: scale(1.07);
  outline: none;
}

/* --- 4. Header --- */
.header {
  background: rgba(42, 52, 66, 0.96);
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 2.2rem;
  border-bottom: 1.5px solid #3c495c;
  box-shadow: 0 2px 18px #191d2499;
  z-index: 2;
}

.agency-name {
  font-size: 1.38rem;
  font-weight: bold;
  color: #b0c9e0;
  letter-spacing: 0.04em;
}
.datetime {
  font-size: 1.05rem;
  color: #b0c9e0;
}

@media (max-width: 700px) {
  .header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 16px 10px;
  }
  .agency-name { font-size: 1.05rem; }
}

/* --- 5. Main Content Area --- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: transparent;
  width: 100%;
  z-index: 1;
}

/* --- 6. Controls (Filters + AI) --- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  align-items: center;
  padding: 20px 22px 12px 22px;
  background: rgba(42, 52, 66, 0.85);
  border-bottom: 1.5px solid #31405a;
  backdrop-filter: blur(5px);
  border-radius: 0 0 18px 18px;
}

.control-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.controls label {
  font-size: 0.99rem;
  font-weight: 500;
  color: #e1e5eb;
  margin-bottom: 3px;
  letter-spacing: 0.03em;
}

.controls select, .controls input[type="text"], .controls input[type="date"] {
  font-size: 1.05rem;
  padding: 7px 13px;
  border: none;
  border-radius: 10px;
  background: #232a39;
  color: #e1e5eb;
  box-shadow: 0 1px 3px #0c0c1e44 inset;
  transition: box-shadow 0.13s;
}
.controls select:focus-visible,
.controls input:focus-visible {
  outline: 2.5px solid #34c759;
  outline-offset: 2px;
}

/* --- 7. iOS-style Button --- */
.ios-btn {
  padding: 10px 28px;
  background: linear-gradient(90deg, #007aff 65%, #00b7ff 100%);
  color: #fff;
  border: none;
  border-radius: 15px;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 3px 12px rgba(0,122,255,0.12);
  cursor: pointer;
  transition: background 0.21s, transform 0.13s, box-shadow 0.19s;
  margin: 0 0 0.5rem 0;
}
.ios-btn:hover, .ios-btn:focus {
  background: linear-gradient(90deg, #005fcc 60%, #0a8ee6 100%);
  transform: scale(1.035);
  box-shadow: 0 7px 24px 0 rgba(0,122,255,0.18);
  outline: none;
}
.ios-btn:active {
  transform: scale(0.98);
}

/* --- 8. AI Summary --- */
.ai-summary {
  margin: 22px auto 10px auto;
  max-width: 530px;
  background: rgba(46, 59, 78, 0.85);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 7px 34px rgba(0,20,90,0.22);
  color: #e1e5eb;
  font-size: 1.04rem;
  line-height: 1.5;
  backdrop-filter: blur(8px) saturate(1.22);
  border: 1.5px solid rgba(44, 75, 111, 0.19);
  animation: fadeUp 0.44s;
}
.ai-summary p { margin-bottom: 18px; }
.ai-logo {
  display: block;
  margin: 0 auto 14px;
  width: 48px;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 1.5px 12px #007aff66;
}

/* --- 9. Dashboard Grid --- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 28px;
  padding: 32px 16px 42px 16px;
  width: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 500px) {
  .dashboard {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 8px;
  }
}

/* --- 10. Cards (Neumorphic + Glass) --- */
.card {
  position: relative;
  background: linear-gradient(135deg, #252c3b 0%, #2e3b4e 100%);
  border-radius: 26px;
  padding: 24px 20px 20px 20px;
  box-shadow:
    0 2.5px 14px 1.5px rgba(30, 40, 64, 0.13),
    0 2.5px 0.5px 0 rgba(255,255,255,0.04) inset;
  color: #e1e5eb;
  text-align: center;
  animation: fadeUp 0.7s;
  transition: box-shadow 0.24s, transform 0.18s;
  opacity: 0;
  animation-fill-mode: forwards;
  animation-delay: 0.12s;
}
.card.clickable { cursor: pointer; }
.card:hover {
  box-shadow: 0 11px 32px 0 rgba(0, 183, 255, 0.29),
    0 3.5px 0.5px 0 rgba(255,255,255,0.06) inset;
  transform: translateY(-6px) scale(1.025);
}

.card h3 {
  font-size: 1.28rem;
  font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: 0.01em;
  color: #8cd4ff;
  text-shadow: 0 2px 16px #228ce8bb;
}
.card-row {
  margin-bottom: 11px;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
}
.card-label {
  font-size: 1.08rem;
  color: #f8fafc;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.card-value {
  display: inline-block;
  font-size: 2.08rem;
  font-weight: 800;
  color: #fff;
  margin-left: 8px;
  text-shadow: 0 2px 16px #1a5276cc, 0 1px 0 #1a1d26;
}
.card-empty {
  font-style: italic;
  color: #95a3b3;
  font-size: 1.02rem;
}

/* --- 11. Mini Chart under Card --- */
canvas.mini-chart {
  width: 34px !important;
  height: 24px !important;
  max-width: 34px !important;
  max-height: 24px !important;
  display: block;
  margin-top: 0.55em;
  border-radius: 7px;
  background: rgba(25,40,64,0.12);
}

/* --- 12. Monthly Chart --- */
.monthly-chart {
  position: relative;
  height: 320px;
  background: linear-gradient(110deg, #232b3f 0%, #283552 100%);
  border-radius: 26px;
  box-shadow: 0 7px 28px rgba(0,32,90,0.13);
  margin-bottom: 12px;
}
#monthlyChartCanvas {
  width: 100% !important;
  height: 100% !important;
  border-radius: 18px;
}
.chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 13px;
  margin: 17px 0;
}
.legend {
  padding: 7px 18px;
  border-radius: 15px;
  font-size: 0.96rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 2px 7px #007aff22;
}
.year-2023 { background: #007aff; }
.year-2024 { background: #34c759; }
.year-2025 { background: #ff9500; }

/* --- 13. Modal Overlay (Glassmorphism) --- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(19, 30, 42, 0.65);
  backdrop-filter: blur(13px) saturate(1.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeUp 0.36s;
}
.modal-overlay[hidden] { display: none; }
.modal-content {
  background: rgba(38, 45, 65, 0.99);
  padding: 2rem 1.5rem 1.3rem 1.5rem;
  border-radius: 24px;
  max-width: 90%;
  max-height: 92%;
  overflow: auto;
  position: relative;
  color: #e8f1ff;
  box-shadow: 0 10px 54px #007aff44;
  border: 1.5px solid rgba(44, 75, 111, 0.16);
  animation: fadeUp 0.41s;
}
.modal-content.dark-mode {
  background: #222b36cc;
  color: #fff;
}
.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 22px;
  font-size: 1.7rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.88;
  transition: opacity 0.17s;
}
.modal-close-btn:hover { opacity: 1; }

/* --- 14. Bar Charts --- */
.bar-chart, .bar-chart-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 12px;
  padding: 18px 12px 18px 12px;
  overflow-x: auto;
  border-radius: 16px;
}
.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 66px;
}
.bar {
  width: 19px;
  border-radius: 10px 10px 0 0;
  transition: transform 0.18s, background 0.22s;
  background: linear-gradient(135deg, #007aff 80%, #34c759 100%);
  margin-bottom: 3px;
}
.bar:hover {
  transform: scaleY(1.12);
  background: linear-gradient(135deg, #0a8ee6 90%, #00b7ff 100%);
}
.bar-label {
  font-size: 0.81rem;
  margin-top: 7px;
  color: #e1e5eb;
  transform: rotate(-40deg);
  transform-origin: top center;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* --- 15. Section Titles --- */
#dashboard-title {
  text-align: center;
  font-size: 2.32rem;
  font-weight: 800;
  color: #fff;
  margin-top: 30px;
  margin-bottom: 12px;
  letter-spacing: 0.03em;
  width: 100%;
  text-shadow:
    0 2px 12px rgba(0, 183, 255, 0.18),
    0 1px 0 #222,
    0 6px 38px #34c75922;
  padding: 0 0;
  display: block;
  user-select: none;
}

/* --- 16. Centered Button Group --- */
.center-button-group {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 100%;
}
.center-button-group .ios-btn {
  margin: 28px 0;
  display: block;
}

/* --- 17. Animations --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(32px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- 18. Misc. Responsive --- */
@media (max-width: 600px) {
  .header, .controls, .modal-content { border-radius: 0; }
  .dashboard { gap: 14px; }
  .ai-summary { max-width: 97vw; }
}

@media (max-width: 400px) {
  .dashboard { padding: 7px; }
  .card { padding: 13px 7px; }
}

@media (max-width: 350px) {
  .controls select,
  .controls button {
    font-size: 0.93rem;
    padding: 5px 7px;
  }
}

