/* ============================================
   Cantaloupe - Dashboard Stylesheet
   Layout: sidebar glass + content area (theo ảnh 3)
   ============================================ */

.dash-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.dash-sidebar {
  width: 258px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
  padding: 22px 16px; display: flex; flex-direction: column;
  background: rgba(255,255,255,.55); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(255,255,255,.6);
}
.dash-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--green-800); padding: 6px 10px 20px; }
.dash-brand:hover { text-decoration: none; }
.dash-brand .logo { width: 36px; height: 36px; border-radius: 11px;
  background: radial-gradient(circle at 30% 30%, var(--melon-500), var(--green-600)); display: grid; place-items: center; font-size: 19px; }

.dash-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-nav a {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px; border-radius: 14px;
  color: var(--slate-700); font-weight: 600; font-size: 15px; transition: background .18s, color .18s;
}
.dash-nav a:hover { background: rgba(255,255,255,.7); color: var(--green-800); text-decoration: none; }
.dash-nav a.active { background: var(--green-600); color: #fff; box-shadow: 0 6px 16px rgba(22,163,74,.35); }
.dash-nav a .ic { font-size: 19px; width: 22px; text-align: center; }

.sidebar-foot { margin-top: auto; padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 14px; background: rgba(255,255,255,.6); }
.user-chip .avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,var(--green-500),var(--melon-500));
  display: grid; place-items: center; color: #fff; font-weight: 700; flex-shrink: 0; }
.user-chip .u-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.user-chip .u-role { font-size: 12px; color: var(--slate-500); }

/* ---------- Main content ---------- */
.dash-main { flex: 1; min-width: 0; padding: 26px 32px 48px; }
.dash-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.dash-topbar .greet h1 { font-size: 26px; margin: 0; color: var(--green-900); }
.dash-topbar .greet p { margin: 2px 0 0; color: var(--slate-500); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.7);
  display: grid; place-items: center; cursor: pointer; font-size: 19px; position: relative; box-shadow: var(--shadow-sm); }
.icon-btn:hover { background: #fff; }
.icon-btn .notif-dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--cal-alert); border: 2px solid #fff; }

/* ---------- Widgets ---------- */
.widgets { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; }
.w { grid-column: span 12; }
.w-3 { grid-column: span 3; } .w-4 { grid-column: span 4; } .w-6 { grid-column: span 6; }
.w-8 { grid-column: span 8; } .w-9 { grid-column: span 9; }

.panel {
  background: rgba(255,255,255,.72); border: 1px solid rgba(255,255,255,.7); border-radius: 22px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: 22px 24px; box-shadow: 0 8px 26px rgba(20,83,45,.08);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 17px; color: var(--green-900); }
.panel-head .sub { font-size: 13px; color: var(--slate-500); }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .stat-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; }
.stat .stat-val { font-size: 32px; font-weight: 800; color: var(--ink); line-height: 1; }
.stat .stat-label { color: var(--slate-500); font-size: 14px; }
.stat .stat-trend { font-size: 12px; font-weight: 700; }
.trend-up { color: var(--green-600); } .trend-down { color: var(--cal-alert); }
.ic-green { background: var(--green-100); color: var(--green-700); }
.ic-red { background: #fee2e2; color: var(--cal-alert); }
.ic-blue { background: #dbeafe; color: #2563eb; }
.ic-amber { background: var(--melon-100); color: var(--melon-600); }

/* Donut center label */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--slate-700); }
.legend-row b { margin-left: auto; }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; }

/* Alert card in dashboard */
.alert-strip { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 18px;
  background: linear-gradient(120deg, #fef2f2, #fff5f5); border: 1px solid #fecaca; }
.alert-strip .a-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--cal-alert); color: #fff; display: grid; place-items: center; font-size: 24px; flex-shrink: 0; animation: pulseRed 1.4s infinite; }
.alert-strip .a-main { flex: 1; min-width: 0; }
.alert-strip .a-main h4 { margin: 0 0 2px; color: #b91c1c; font-size: 16px; }
.alert-strip .a-main p { margin: 0; font-size: 13px; color: var(--slate-600); }
@keyframes pulseRed { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } }

/* ---------- Camera page ---------- */
.cam-grid { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 20px; }
.cam-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 220px; margin: 0 auto; }
.cam-btn { aspect-ratio: 1; border-radius: 16px; border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.85);
  font-size: 24px; cursor: pointer; display: grid; place-items: center; box-shadow: var(--shadow-sm); transition: transform .06s, background .15s; color: var(--green-700); }
.cam-btn:hover { background: var(--green-600); color: #fff; }
.cam-btn:active { transform: scale(.93); }
.cam-btn.center { background: var(--green-600); color: #fff; font-size: 14px; font-weight: 700; }
.cam-btn.blank { visibility: hidden; }

/* Garden 2D map */
.garden-map { display: grid; gap: 10px; }
.garden-row { display: flex; align-items: center; gap: 8px; }
.garden-row .row-label { width: 62px; font-size: 12px; font-weight: 700; color: var(--slate-500); flex-shrink: 0; }
.plant-cells { display: flex; gap: 7px; flex-wrap: wrap; }
.plant { width: 26px; height: 26px; border-radius: 8px; background: var(--green-100); border: 1px solid var(--green-500);
  display: grid; place-items: center; font-size: 13px; cursor: pointer; position: relative; transition: transform .1s; }
.plant:hover { transform: scale(1.15); z-index: 2; }
.plant.sick { background: var(--cal-alert); border-color: #991b1b; color: #fff; animation: blink 1s infinite; }
.plant.scanning { border-color: var(--melon-500); box-shadow: 0 0 0 2px var(--melon-100); }
@keyframes blink { 50% { opacity: .45; } }

/* disease photo */
.disease-photo { aspect-ratio: 4/3; border-radius: 16px; overflow: hidden; position: relative; background: linear-gradient(160deg,#dcfce7,#bbf7d0); }
.disease-photo .bbox { position: absolute; border: 3px solid var(--cal-alert); border-radius: 6px; }
.disease-photo .bbox .tag { position: absolute; top: -26px; left: -3px; background: var(--cal-alert); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }

/* treatment box */
.treat-step { display: flex; gap: 12px; margin-bottom: 14px; }
.treat-step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--green-600); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.treat-step p { margin: 0; font-size: 14px; color: var(--slate-700); }

/* disease log */
.log-item { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid rgba(148,163,184,.25); }
.log-item:last-child { border-bottom: none; }
.log-thumb { width: 56px; height: 56px; border-radius: 12px; background: linear-gradient(160deg,#dcfce7,#bbf7d0); flex-shrink: 0; display: grid; place-items: center; font-size: 24px; }
.log-thumb.danger { background: linear-gradient(160deg,#fee2e2,#fecaca); }
.log-item .log-main { flex: 1; min-width: 0; }
.log-item .log-main h4 { margin: 0 0 2px; font-size: 15px; }
.log-item .log-main .muted { font-size: 12px; }

/* ---------- Smart Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-title { font-size: 20px; font-weight: 800; color: var(--green-900); min-width: 190px; text-align: center; }
.view-switch { display: inline-flex; background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px; gap: 2px; border: 1px solid rgba(255,255,255,.7); }
.view-switch button { border: none; background: none; padding: 7px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--slate-600); font-family: inherit; }
.view-switch button.active { background: var(--green-600); color: #fff; }

.cal-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; font-size: 13px; }
.cal-legend .lg { display: flex; align-items: center; gap: 7px; color: var(--slate-600); }
.cal-legend .sw { width: 14px; height: 14px; border-radius: 5px; }

/* month grid */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { text-align: center; font-weight: 700; font-size: 13px; color: var(--slate-500); padding: 6px 0; }
.cal-cell { min-height: 108px; border-radius: 14px; background: rgba(255,255,255,.6); border: 1px solid rgba(255,255,255,.7);
  padding: 8px; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.cal-cell.other-month { opacity: .45; }
.cal-cell.today { border-color: var(--melon-500); box-shadow: 0 0 0 2px var(--melon-100); }
.cal-cell .day-num { font-size: 13px; font-weight: 700; color: var(--slate-600); }
.cal-cell.today .day-num { color: var(--melon-600); }
.cal-event { font-size: 11px; padding: 3px 7px; border-radius: 7px; color: #fff; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.35; }
.cal-event.done { opacity: .55; text-decoration: line-through; }
.ev-system { background: var(--cal-system); }
.ev-manual { background: var(--cal-manual); }
.ev-alert { background: var(--cal-alert); animation: blink 1.3s infinite; }
.ev-alert.processing { animation: none; background: var(--melon-600); }
.ev-alert.done { animation: none; }
.cal-more { font-size: 10px; color: var(--slate-500); }

/* week/day list view */
.cal-list { display: flex; flex-direction: column; gap: 10px; }
.cal-list-day { }
.cal-list-day .cld-head { font-weight: 700; color: var(--green-800); margin: 10px 0 6px; font-size: 15px; }
.cal-list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: rgba(255,255,255,.7); border: 1px solid rgba(255,255,255,.7); }
.cal-list-item .bar { width: 5px; align-self: stretch; border-radius: 5px; }
.cal-list-item .cli-main { flex: 1; min-width: 0; }
.cal-list-item .cli-main h4 { margin: 0; font-size: 15px; }
.cal-list-item .cli-main .muted { font-size: 12px; }
.cal-list-item.done .cli-main h4 { text-decoration: line-through; color: var(--slate-400); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 48px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--slate-300); border-radius: 999px; transition: .25s; cursor: pointer; }
.switch .slider:before { content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .25s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--green-600); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* devices */
.device-row { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid rgba(148,163,184,.22); }
.device-row:last-child { border-bottom: none; }
.device-ic { width: 50px; height: 50px; border-radius: 14px; background: var(--green-100); display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.device-main { flex: 1; min-width: 0; }
.device-main h4 { margin: 0 0 2px; font-size: 16px; }
.device-main .muted { font-size: 13px; }
.battery { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--slate-600); }

/* log table for traceability */
.trace-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(148,163,184,.2); font-size: 14px; }
.trace-item:last-child { border-bottom: none; }
.trace-item .t-time { color: var(--slate-400); font-size: 12px; white-space: nowrap; min-width: 116px; }
.trace-item .t-dot { color: var(--green-600); }

@media (max-width: 1000px) {
  .cam-grid { grid-template-columns: 1fr; }
  .w-3 { grid-column: span 6; } .w-4 { grid-column: span 6; } .w-8, .w-9 { grid-column: span 12; }
}
@media (max-width: 820px) {
  .dash-sidebar { position: fixed; z-index: 200; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .dash-sidebar.open { transform: none; }
  .dash-main { padding: 20px 16px 40px; }
  .w-3, .w-4 { grid-column: span 12; }
  .cal-cell { min-height: 76px; }
}
.mobile-menu-btn { display: none; }
@media (max-width: 820px) { .mobile-menu-btn { display: grid; } }

/* ---------- Giai đoạn sinh trưởng ---------- */
.plant.st { border: 1px solid rgba(15,23,42,.15); }
.plant.pollinated { outline: 2px dashed #92400e; outline-offset: 1px; }
.plant.event { animation: blink 1.2s infinite; }
.alert-strip.stage { background: linear-gradient(120deg, #f5f3ff, #faf5ff); border-color: #ddd6fe; }
.alert-strip.stage .a-ic { background: var(--cal-ai); animation: pulsePurple 1.6s infinite; }
.alert-strip.stage .a-main h4 { color: #6d28d9; }
.alert-strip.ok { background: linear-gradient(120deg,#f0fdf4,#ecfdf5); border-color: #bbf7d0; }
.alert-strip.ok .a-ic { background: var(--green-600); animation: none; }
.alert-strip.ok .a-main h4 { color: var(--green-800); }
@keyframes pulsePurple { 0%,100% { box-shadow: 0 0 0 0 rgba(139,92,246,.5); } 50% { box-shadow: 0 0 0 10px rgba(139,92,246,0); } }
.ev-ai { background: var(--cal-ai); }
.ev-ai.processing { background: var(--melon-600); }
.ev-ai.pending { animation: blink 1.3s infinite; }
.row-progress { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(148,163,184,.2); font-size: 14px; }
.row-progress:last-child { border-bottom: none; }
.row-progress .rp-name { width: 58px; font-weight: 700; color: var(--slate-600); flex-shrink: 0; }
.row-progress .rp-bar { flex: 1; display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--slate-100); min-width: 60px; }
.log-thumb.st { overflow: hidden; padding: 0; }
.log-thumb.st svg { display: block; }

/* Dòng thời gian sinh trưởng */
.row-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.row-tabs button { border: 1px solid rgba(148,163,184,.35); background: rgba(255,255,255,.8); padding: 8px 16px; border-radius: 999px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--slate-700); }
.row-tabs button.active { background: var(--green-600); border-color: var(--green-600); color: #fff; }
.gantt { position: relative; margin: 26px 0 8px; }
.gantt-bar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; }
.gantt-bar div { height: 100%; }
.gantt-today { position: absolute; top: -20px; bottom: -6px; border-left: 2px dashed var(--ink); }
.gantt-today span { position: absolute; top: -2px; left: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.gantt-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--slate-400); margin-top: 4px; }
.tl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.tl-item { background: rgba(255,255,255,.8); border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,.8); box-shadow: var(--shadow-sm); }
.tl-item .stage-photo { border-radius: 0; aspect-ratio: 4/3; }
.tl-item .tl-body { padding: 10px 12px 14px; font-size: 13px; }
.tl-item .tl-day { font-weight: 800; color: var(--green-800); font-size: 14px; }
.tl-item.future { opacity: .55; border-style: dashed; border-color: var(--slate-300); }
.tl-item.future .stage-photo { filter: grayscale(.6); }

/* Trang Trợ lý AI / Nhận diện ảnh khi mở từ thanh bên Dashboard */
.in-dash .section { padding: 0 0 24px; }
.in-dash .section-alt { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.in-dash .container { max-width: none; padding: 0; }
.in-dash .page-intro { display: none; }
.in-dash .section-head { text-align: left; max-width: none; margin: 8px 0 18px; }
.in-dash .section-head h2 { font-size: 22px; }
