/* =============================================================
   SmartAzaan Device Management Dashboard – Stylesheet
   =============================================================
   Sections
   1.  Variables
   2.  Reset
   3.  Typography
   4.  Layout
   5.  Header
   6.  Navigation
   7.  Buttons
   8.  Cards
   9.  Dashboard (Welcome & Stats)
   10. Search
   11. Forms
   12. Tables
   13. Status Badges
   14. Footer
   15. Responsive Media Queries
   ============================================================= */

/* ─────────────────────────────────────────────
   1. Variables
───────────────────────────────────────────── */
:root {
  --color-primary:        #5B2ED6;
  --color-primary-hover:  #4A24B0;
  --color-secondary:      #7D5BFF;
  --color-bg:             #F6F8FC;
  --color-card:           #FFFFFF;
  --color-border:         #E5E7EB;
  --color-text:           #111827;
  --color-text-secondary: #6B7280;
  --color-success:        #16A34A;
  --color-success-bg:     #DCFCE7;
  --color-info:           #2563EB;
  --color-info-bg:        #DBEAFE;
  --color-error:          #DC2626;
  --color-error-bg:       #FEE2E2;
  --color-row-hover:      #FAFAFA;

  --font-family:          'Inter', 'Segoe UI', Arial, sans-serif;
  --font-weight-body:     400;
  --font-weight-button:   500;
  --font-weight-heading:  600;
  --font-weight-stat:     700;

  --radius-sm:   6px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  --shadow-header: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-card:   0 1px 4px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);

  --transition-fast: 150ms ease;

  --max-width: 1600px;
  --header-height: 72px;
}

/* ─────────────────────────────────────────────
   2. Reset
───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-family);
  font-weight: var(--font-weight-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ─────────────────────────────────────────────
   3. Typography
───────────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: var(--font-weight-heading); line-height: 1.3; }
.text-secondary { color: var(--color-text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

/* ─────────────────────────────────────────────
   4. Layout
───────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 28px;
}
main { flex: 1; padding: 28px 0 40px; }

/* ─────────────────────────────────────────────
   5. Header
───────────────────────────────────────────── */
header {
  height: var(--header-height);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-header);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.logo-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-text { line-height: 1.1; }
.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: -.2px;
}
.logo-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--color-text-secondary);
  text-transform: uppercase;
}

/* ─────────────────────────────────────────────
   6. Navigation
───────────────────────────────────────────── */
nav { flex: 1; }
.nav-list {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-item { position: relative; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: var(--font-weight-body);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
}
.nav-link:hover {
  background: #F3F4F6;
  color: var(--color-text);
}
.nav-link.active {
  color: var(--color-primary);
  font-weight: var(--font-weight-button);
}
.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -17px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
}
.nav-icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

/* Header right controls */
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.icon-btn:hover { background: #F3F4F6; color: var(--color-text); }
.icon-btn svg { width: 20px; height: 20px; }

.user-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.user-menu:hover { background: #F3F4F6; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chevron-icon { width: 16px; height: 16px; color: var(--color-text-secondary); }

/* Hamburger (hidden on desktop) */
.hamburger { display: none; }

/* ─────────────────────────────────────────────
   7. Buttons
───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: var(--font-weight-button);
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-outline {
  background: var(--color-card);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-outline:hover { background: #F9FAFB; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: #F9FAFB; color: var(--color-text); }

/* ─────────────────────────────────────────────
   8. Cards
───────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
}

/* ─────────────────────────────────────────────
   9. Dashboard – Welcome & Stats
───────────────────────────────────────────── */
.welcome-card {
  padding: 28px 32px;
  margin-bottom: 22px;
}
.welcome-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.welcome-heading {
  font-size: 20px;
  font-weight: var(--font-weight-heading);
  margin-bottom: 4px;
}
.welcome-desc { color: var(--color-text-secondary); font-size: 14px; }
.welcome-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
.stat-card {
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap svg { width: 24px; height: 24px; }
.stat-icon-wrap.purple { background: #EDE9FF; color: var(--color-primary); }
.stat-icon-wrap.blue   { background: var(--color-info-bg); color: var(--color-info); }
.stat-icon-wrap.green  { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon-wrap.red    { background: var(--color-error-bg); color: var(--color-error); }

.stat-body { min-width: 0; }
.stat-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 2px;
}
.stat-value {
  font-size: 26px;
  font-weight: var(--font-weight-stat);
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-desc {
  font-size: 12px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-green { background: var(--color-success); }
.dot-red   { background: var(--color-error); }

/* ─────────────────────────────────────────────
   10. Search
───────────────────────────────────────────── */
.search-wrap {
  position: relative;
  width: 280px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-secondary);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--color-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.search-input::placeholder { color: var(--color-text-secondary); }
.search-input:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(91,46,214,.1);
}

/* ─────────────────────────────────────────────
   11. Forms
───────────────────────────────────────────── */
.checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* ─────────────────────────────────────────────
   12. Tables
───────────────────────────────────────────── */
.device-section { margin-bottom: 22px; }
.device-card { overflow: hidden; }

.device-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  gap: 16px;
  border-bottom: 1px solid var(--color-border);
}
.device-title {
  font-size: 16px;
  font-weight: var(--font-weight-heading);
  color: var(--color-primary);
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 480px;
}
.table-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.table-scroll::-webkit-scrollbar-track { background: #F3F4F6; }
.table-scroll::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 9999px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #9CA3AF; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  padding: 11px 14px;
  text-align: left;
  font-weight: var(--font-weight-button);
  font-size: 12.5px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  background: var(--color-card);
}
thead th:first-child { padding-left: 24px; }
thead th:last-child  { padding-right: 24px; }

tbody tr {
  border-bottom: 1px solid #F3F4F6;
  transition: background var(--transition-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--color-row-hover); }

tbody td {
  padding: 13px 14px;
  vertical-align: middle;
  white-space: nowrap;
  color: var(--color-text);
}
tbody td:first-child { padding-left: 24px; }
tbody td:last-child  { padding-right: 24px; }

.td-did { font-weight: var(--font-weight-button); }
.td-mono { font-family: 'Courier New', monospace; font-size: 13px; letter-spacing: .02em; }
.td-muted { color: var(--color-text-secondary); }

/* Table action buttons */
.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.action-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.action-btn:hover { background: #F3F4F6; color: var(--color-primary); }
.action-btn svg { width: 16px; height: 16px; }
.action-btn.view { color: var(--color-primary); }
.action-btn.edit { color: var(--color-info); }

/* ─────────────────────────────────────────────
   13. Status Badges
───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: var(--font-weight-button);
  white-space: nowrap;
}
.badge-customer { background: var(--color-success-bg); color: var(--color-success); }
.badge-factory  { background: var(--color-info-bg);    color: var(--color-info); }
.badge-enabled  { background: var(--color-success-bg); color: var(--color-success); }
.badge-disabled { background: var(--color-error-bg);   color: var(--color-error); }

/* ─────────────────────────────────────────────
   14. Footer
───────────────────────────────────────────── */
footer {
  padding: 20px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 13px;
  color: var(--color-text-secondary);
  background: var(--color-card);
}

/* ─────────────────────────────────────────────
   15. Responsive Media Queries
───────────────────────────────────────────── */

/* Laptop (≤1280px) */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
  .nav-list { display: none; }
  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
  }
  .hamburger:hover { background: #F3F4F6; }
  .hamburger svg { width: 22px; height: 22px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  main { padding: 16px 0 32px; }

  .welcome-inner { flex-direction: column; align-items: flex-start; }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn { flex: 1; justify-content: center; }

  .stats-grid { grid-template-columns: 1fr; gap: 12px; }

  .device-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar-right { flex-direction: column; }
  .search-wrap { width: 100%; }
  .btn-ghost { justify-content: center; }

  .icon-btn:not(:last-child) { display: none; }
  .logo-sub { display: none; }
}

.modal-overlay {
    position: fixed;
    inset: 0;

    background: rgba(15, 23, 42, 0.45);

    display: none;
    align-items: center;
    justify-content: center;

    padding: 20px;

    z-index: 1000;
}

.modal-overlay.open {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 520px;

    background: #fff;

    border-radius: 16px;

    box-shadow:
        0 20px 50px rgba(15, 23, 42, 0.18);

    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    padding: 24px;

    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    margin: 0 0 5px;

    font-size: 20px;
}

.modal-header p {
    margin: 0;

    font-size: 13px;

    color: var(--color-text-secondary);
}

.modal-close {
    border: 0;
    background: transparent;

    font-size: 28px;
    line-height: 1;

    cursor: pointer;

    color: var(--color-text-secondary);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;

    margin-bottom: 7px;

    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;

    box-sizing: border-box;

    padding: 11px 12px;

    border: 1px solid var(--color-border);
    border-radius: 8px;

    font: inherit;

    background: #fff;
}

.form-group input[readonly] {
    background: #F8FAFC;
}

.form-group small {
    display: block;

    margin-top: 6px;

    color: var(--color-text-secondary);

    font-size: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;

    padding: 18px 24px;

    border-top: 1px solid var(--color-border);

    background: #FAFAFA;
}

.form-message {
    display: none;

    padding: 10px 12px;

    border-radius: 8px;

    font-size: 13px;
}

.form-message.error {
    display: block;

    background: #FEE2E2;
    color: #B91C1C;
}

.form-message.success {
    display: block;

    background: #DCFCE7;
    color: #15803D;
}
