/* ============================================================
   AURAWATT CLOUD — Components: tabs, charts, energy flow,
   modals, toasts, settings, alerts, firmware, support
   ============================================================ */

/* ---------------- Tabs (device detail) ---------------- */
.aw-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--aw-line); overflow-x: auto; }
.aw-tabs .aw-tab {
  border: 0; background: transparent; padding: 12px 2px 13px; margin-bottom: -1px;
  font-size: 14px; font-weight: 600; color: #64748B; font-family: var(--aw-font);
  border-bottom: 2.5px solid transparent; white-space: nowrap; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.aw-tabs .aw-tab:hover { color: var(--aw-ink); }
.aw-tabs .aw-tab.active { color: var(--aw-primary); border-bottom-color: var(--aw-primary); }
.aw-tabpane { display: none; }
.aw-tabpane.active { display: block; }

/* ---------------- Segmented toggle ---------------- */
.aw-seg { display: inline-flex; background: #F1F4F9; border-radius: 9px; padding: 3px; gap: 2px; }
.aw-seg button {
  border: 0; background: transparent; padding: 6.5px 14px; border-radius: 7px;
  font-size: 12.5px; font-weight: 600; color: #64748B; cursor: pointer; font-family: var(--aw-font);
  transition: background .15s, color .15s, box-shadow .15s;
}
.aw-seg button:hover { color: var(--aw-ink); }
.aw-seg button.active { background: #fff; color: var(--aw-ink); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.aw-seg.pill button { background: transparent; box-shadow: none; }
.aw-seg.pill button.active { background: var(--aw-primary-soft); color: var(--aw-primary); }

/* ---------------- Chart containers ---------------- */
.aw-chart { width: 100%; }
.aw-chart-donut-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.aw-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.aw-donut-center .dc-label { font-size: 12px; color: var(--aw-muted); font-weight: 500; }
.aw-donut-center .dc-value { font-size: 30px; font-weight: 800; color: var(--aw-ink); line-height: 1.1; }
.aw-donut-center .dc-value small { font-size: 13px; color: var(--aw-muted); font-weight: 600; }
.aw-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.aw-legend .lg { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: #5B6B84; }
.aw-legend .lg i { width: 9px; height: 9px; border-radius: 2.5px; display: inline-block; }
.aw-legend .lg b { color: var(--aw-ink); font-weight: 700; }

/* ---------------- Energy flow diagram ---------------- */
.awflow-card { position: relative; }
.awflow-svg { width: 100%; height: auto; display: block; }
.awflow-svg text { font-family: var(--aw-font); }
.awflow-svg .node-rect { fill: #fff; stroke: #E3E8F0; filter: drop-shadow(0 3px 10px rgba(16,24,40,.07)); }
.awflow-svg .node-ico-rect { rx: 12; }
.awflow-svg .n-title { font-size: 12.5px; font-weight: 600; fill: #64748B; }
.awflow-svg .n-value { font-size: 19px; font-weight: 800; fill: #1E2A3B; letter-spacing: -.01em; }
.awflow-svg .n-unit { font-size: 11.5px; font-weight: 600; fill: #8A94A6; }
.awflow-svg .n-sub { font-size: 11px; font-weight: 500; fill: #8A94A6; }
.awflow-svg .edge { fill: none; stroke-linecap: round; stroke-width: 2.6; opacity: .35; }
.awflow-svg .edge-flow { fill: none; stroke-linecap: round; stroke-width: 2.6; stroke-dasharray: 7 10; animation: awDash 1.05s linear infinite; }
.awflow-svg .edge-flow.rev { animation-direction: reverse; }
.awflow-svg .edge-flow.paused { animation-play-state: paused; opacity: .25; }
@keyframes awDash { to { stroke-dashoffset: -17; } }
.c-pv { stroke: var(--aw-pv); } .c-bat { stroke: var(--aw-bat); }
.c-grid { stroke: var(--aw-grid); } .c-load { stroke: var(--aw-load); }
.awflow-svg .pulse { animation: awPulse 2.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes awPulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.awflow-svg .spin { animation: awSpin 7s linear infinite; transform-origin: center; transform-box: fill-box; }
@keyframes awSpin { to { transform: rotate(360deg); } }
.awflow-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 12px; margin-top: 12px; border-top: 1px dashed var(--aw-line); }
.awflow-legend .lg { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #5B6B84; font-weight: 500; }
.awflow-legend .lg i { width: 9px; height: 9px; border-radius: 3px; }

/* ---------------- Floating action button (device detail) ---------------- */
.aw-fab-wrap { position: fixed; right: 26px; bottom: 26px; z-index: 1045; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.aw-fab-menu { display: none; flex-direction: column; gap: 6px; }
.aw-fab-menu.open { display: flex; }
.aw-fab-menu a {
  background: #fff; border: 1px solid var(--aw-line); border-radius: 10px;
  padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--aw-text);
  display: inline-flex; align-items: center; gap: 9px; box-shadow: var(--aw-shadow);
}
.aw-fab-menu a i { color: var(--aw-primary); }
.aw-fab-menu a:hover { color: var(--aw-primary); border-color: var(--aw-primary-soft); background: var(--aw-primary-50); }
.aw-fab {
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--aw-primary); color: #fff; font-size: 21px;
  box-shadow: 0 8px 22px rgba(37, 99, 235, .42);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.aw-fab:hover { background: var(--aw-primary-hover); transform: scale(1.05); }
.aw-fab i { transition: transform .2s; }
.aw-fab.open i { transform: rotate(45deg); }

/* ---------------- Modals ---------------- */
.modal-content.aw-modal { border: 0; border-radius: 16px; box-shadow: var(--aw-shadow-lg); font-family: var(--aw-font); }
.modal-content.aw-modal .modal-header { border-bottom: 0; padding: 22px 24px 6px; }
.modal-content.aw-modal .modal-title { font-size: 19px; font-weight: 800; color: var(--aw-ink); }
.modal-content.aw-modal .modal-sub { color: #64748B; font-size: 13px; margin-top: 3px; }
.modal-content.aw-modal .modal-body { padding: 16px 24px 8px; }
.modal-content.aw-modal .modal-footer { border-top: 0; padding: 12px 24px 22px; gap: 10px; }
.aw-modal .form-label { font-size: 13px; font-weight: 600; color: var(--aw-ink); margin-bottom: 6px; }
.aw-modal .form-label .req { color: var(--aw-red); }
.aw-perm-table { width: 100%; border-collapse: collapse; }
.aw-perm-table th {
  background: var(--aw-thead); color: #5B6B84; font-size: 11.5px; font-weight: 600;
  padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--aw-line); white-space: nowrap;
}
.aw-perm-table th:first-child { text-align: left; border-radius: 8px 0 0 8px; }
.aw-perm-table th:last-child { border-radius: 0 8px 8px 0; }
.aw-perm-table td { padding: 9px 12px; border-bottom: 1px solid #F1F4F9; font-size: 13px; color: var(--aw-ink); text-align: center; }
.aw-perm-table td:first-child { text-align: left; font-weight: 500; }
.aw-perm-table tbody tr:hover { background: #F8FAFD; }
.aw-perm-table input { accent-color: var(--aw-primary); width: 15px; height: 15px; cursor: pointer; }

/* ---------------- Toasts ---------------- */
.aw-toasts { position: fixed; right: 22px; bottom: 22px; z-index: 1090; display: flex; flex-direction: column; gap: 10px; }
.aw-toast {
  background: #fff; border: 1px solid var(--aw-line); border-left: 4px solid var(--aw-primary);
  border-radius: 12px; box-shadow: var(--aw-shadow-lg); padding: 13px 16px;
  display: flex; align-items: flex-start; gap: 11px; min-width: 290px; max-width: 380px;
  animation: awToastIn .25s ease;
}
.aw-toast.success { border-left-color: var(--aw-green); }
.aw-toast.error { border-left-color: var(--aw-red); }
.aw-toast i { font-size: 17px; margin-top: 1px; color: var(--aw-primary); }
.aw-toast.success i { color: var(--aw-green); }
.aw-toast.error i { color: var(--aw-red); }
.aw-toast .t-title { font-size: 13.5px; font-weight: 700; color: var(--aw-ink); }
.aw-toast .t-msg { font-size: 12.5px; color: #64748B; margin-top: 1px; }
@keyframes awToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.aw-toast.hideout { transition: opacity .3s, transform .3s; opacity: 0; transform: translateY(8px); }

/* ---------------- Settings ---------------- */
.aw-settings { display: grid; grid-template-columns: 232px 1fr; gap: 18px; align-items: start; }
.aw-subnav { background: #fff; border-radius: var(--aw-radius); box-shadow: var(--aw-shadow); padding: 12px; position: sticky; top: 86px; }
.aw-subnav .sn-label { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--aw-muted); padding: 10px 12px 6px; }
.aw-subnav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px;
  color: #55627A; font-size: 13.5px; font-weight: 500; margin: 1px 0;
}
.aw-subnav a i { font-size: 16px; width: 19px; text-align: center; }
.aw-subnav a:hover { background: #F4F7FC; color: var(--aw-ink); }
.aw-subnav a.active { background: var(--aw-primary-soft); color: var(--aw-primary); font-weight: 600; }
.aw-panel { display: none; }
.aw-panel.active { display: block; }
.aw-switchrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 2px; border-bottom: 1px solid #F1F4F9; }
.aw-switchrow:last-child { border-bottom: 0; }
.aw-switchrow .sr-title { font-size: 13.5px; font-weight: 600; color: var(--aw-ink); }
.aw-switchrow .sr-desc { font-size: 12.5px; color: var(--aw-muted); margin-top: 2px; max-width: 480px; }
.aw-switchrow .form-check { margin: 0; }

/* ---------------- Work mode cards (data control) ---------------- */
.aw-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.aw-mode {
  border: 1.5px solid var(--aw-line-strong); border-radius: 12px; padding: 15px 16px;
  cursor: pointer; background: #fff; transition: border-color .15s, background .15s;
}
.aw-mode:hover { border-color: #BFD3F5; }
.aw-mode.active { border-color: var(--aw-primary); background: var(--aw-primary-50); }
.aw-mode .m-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--aw-tile); display: flex; align-items: center; justify-content: center; font-size: 18px; color: #5B6B84; margin-bottom: 10px; }
.aw-mode.active .m-ico { background: var(--aw-primary-soft); color: var(--aw-primary); }
.aw-mode .m-title { font-size: 13.5px; font-weight: 700; color: var(--aw-ink); }
.aw-mode .m-desc { font-size: 12px; color: var(--aw-muted); margin-top: 3px; line-height: 1.45; }
.form-range-aw { accent-color: var(--aw-primary); width: 100%; }

/* ---------------- Alerts ---------------- */
.aw-alert-item { display: flex; gap: 14px; padding: 15px 18px; border-bottom: 1px solid #F1F4F9; align-items: flex-start; }
.aw-alert-item:last-child { border-bottom: 0; }
.aw-alert-item:hover { background: #F8FAFD; }
.aw-alert-item .a-ico { width: 40px; height: 40px; border-radius: 12px; flex: 0 0 40px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.aw-alert-item .a-ico.fault { background: var(--aw-red-bg); color: var(--aw-red); }
.aw-alert-item .a-ico.warn { background: var(--aw-orange-bg); color: var(--aw-orange); }
.aw-alert-item .a-ico.info { background: var(--aw-primary-soft); color: var(--aw-primary); }
.aw-alert-item .a-title { font-size: 13.5px; font-weight: 700; color: var(--aw-ink); }
.aw-alert-item .a-meta { font-size: 12.5px; color: #64748B; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.aw-alert-item .a-meta i { margin-right: 4px; }
.aw-alert-item .a-right { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.aw-alert-item .a-time { font-size: 12px; color: var(--aw-muted); }

/* ---------------- Firmware ---------------- */
.aw-fw-progress { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.aw-fw-progress .bar { flex: 1; height: 6px; border-radius: 6px; background: #E7ECF3; overflow: hidden; }
.aw-fw-progress .bar > span { display: block; height: 100%; border-radius: 6px; background: var(--aw-primary); transition: width .6s ease; }
.aw-fw-progress .pct { font-size: 12px; font-weight: 700; color: var(--aw-primary); min-width: 34px; text-align: right; }
.aw-ver { font-family: var(--aw-mono); font-size: 12.5px; }
.aw-release { border: 1px solid var(--aw-line); border-radius: 12px; padding: 15px 17px; }
.aw-release + .aw-release { margin-top: 12px; }
.aw-release .r-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aw-release .r-ver { font-family: var(--aw-mono); font-weight: 700; color: var(--aw-ink); font-size: 13.5px; }
.aw-release .r-date { font-size: 12px; color: var(--aw-muted); margin-left: auto; }
.aw-release ul { margin: 9px 0 0; padding-left: 18px; font-size: 12.5px; color: #5B6B84; }
.aw-release ul li { margin: 3px 0; }

/* ---------------- Datalogger signal bars ---------------- */
.aw-signal { display: inline-flex; align-items: flex-end; gap: 2.5px; height: 14px; }
.aw-signal span { width: 3.5px; border-radius: 2px; background: #DDE4EE; }
.aw-signal span:nth-child(1) { height: 35%; } .aw-signal span:nth-child(2) { height: 58%; }
.aw-signal span:nth-child(3) { height: 78%; } .aw-signal span:nth-child(4) { height: 100%; }
.aw-signal.s4 span { background: var(--aw-green); }
.aw-signal.s3 span:not(:nth-child(4)) { background: var(--aw-green); }
.aw-signal.s2 span:nth-child(-n+2) { background: var(--aw-orange); }
.aw-signal.s1 span:nth-child(1) { background: var(--aw-red); }

/* ---------------- Support ---------------- */
.aw-contact-card { text-align: center; padding: 24px 18px; border: 1px solid var(--aw-line); border-radius: 14px; background: #fff; }
.aw-contact-card .c-ico { width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 13px; background: var(--aw-primary-soft); color: var(--aw-primary); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.aw-contact-card .c-title { font-size: 14px; font-weight: 700; color: var(--aw-ink); }
.aw-contact-card .c-desc { font-size: 12.5px; color: var(--aw-muted); margin: 4px 0 12px; }
.accordion.aw-acc { --bs-accordion-border-color: var(--aw-line); --bs-accordion-border-radius: 12px; --bs-accordion-btn-focus-box-shadow: none; }
.accordion.aw-acc .accordion-button { font-size: 13.5px; font-weight: 600; color: var(--aw-ink); padding: 15px 18px; }
.accordion.aw-acc .accordion-button:not(.collapsed) { background: var(--aw-primary-50); color: var(--aw-primary); box-shadow: none; }
.accordion.aw-acc .accordion-body { font-size: 13px; color: #5B6B84; padding: 4px 18px 15px; }

/* ---------------- Device detail specifics ---------------- */
.aw-device-hero { text-align: center; }
.aw-device-hero .d-sn { font-size: 16.5px; font-weight: 800; color: var(--aw-ink); word-break: break-all; }
.aw-device-shot { background: linear-gradient(180deg, #F3F5F9, #E9EDF5); border-radius: 12px; padding: 18px; margin: 14px 0; }
.aw-device-shot img { width: 100%; max-width: 230px; display: block; margin: 0 auto; }
.aw-tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.aw-tile-grid .aw-tile { padding: 13px 15px; }
.aw-tile-grid .aw-tile .t-label { font-size: 12px; margin-bottom: 4px; }
.aw-tile-grid .aw-tile .t-value { font-size: 17.5px; }

/* Live metric grid (device energy flow) */
.aw-live-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--aw-line); border-radius: 12px; overflow: hidden; }
.aw-live-grid .lg-cell { background: #FBFCFE; padding: 14px 16px; }
.aw-live-grid .lg-cell .l-label { font-size: 12px; color: #64748B; }
.aw-live-grid .lg-cell .l-value { font-size: 19px; font-weight: 800; color: #3B82F6; margin-top: 3px; }
.aw-live-grid .lg-cell .l-value small { font-size: 12px; color: var(--aw-muted); font-weight: 600; margin-left: 2px; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1199.98px) {
  .aw-settings { grid-template-columns: 200px 1fr; }
}
@media (max-width: 991.98px) {
  .aw-settings { grid-template-columns: 1fr; }
  .aw-subnav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .aw-subnav .sn-label { width: 100%; }
  .aw-subnav a { padding: 8px 11px; }
  .aw-mode-grid { grid-template-columns: 1fr 1fr; }
  .aw-live-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 575.98px) {
  .aw-mode-grid { grid-template-columns: 1fr; }
  .aw-live-grid { grid-template-columns: 1fr; }
  .aw-fab-wrap { right: 16px; bottom: 16px; }
}
