/* ============================================
   ZGRADA APP - Professional Building Management
   Theme: Industrial/Utilitarian with sharp accents
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --bg:          #0f1117;
  --bg2:         #161b27;
  --bg3:         #1e2535;
  --border:      #2a3145;
  --accent:      #3b7fff;
  --accent2:     #00d4aa;
  --text:        #e8ecf4;
  --text2:       #8899b5;
  --text3:       #55667a;

  --ok:          #00d4aa;
  --warning:     #f5a623;
  --problem:     #f06020;
  --critical:    #e53535;

  --sidebar-w:   260px;
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ---- LAYOUT ---- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.3s;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-family: 'Space Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text3);
  font-family: 'Space Mono', monospace;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 8px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg3);
  color: var(--text);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-link .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  opacity: 0.8;
}

.nav-badge {
  margin-left: auto;
  background: var(--critical);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

.nav-badge.warning { background: var(--warning); }
.nav-badge.ok      { background: var(--accent2); }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role {
  font-size: 11px;
  color: var(--text3);
  text-transform: capitalize;
}

.sidebar-user a {
  margin-left: auto;
  color: var(--text3);
  font-size: 18px;
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-user a:hover { color: var(--critical); }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  color: var(--text);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
}

.card-body {
  padding: 22px;
}

.card-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
}

.stat-card.accent::before  { background: var(--accent); }
.stat-card.ok::before      { background: var(--ok); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--critical); }
.stat-card.orange::before  { background: var(--problem); }

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-icon {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 32px;
  opacity: 0.15;
}

/* ---- TABLES ---- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: var(--bg3);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}

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

.btn-success   { background: var(--ok); color: #0a1a14; }
.btn-success:hover { background: #00bfa0; }

.btn-warning   { background: var(--warning); color: #1a0f00; }
.btn-warning:hover { background: #e09600; }

.btn-danger    { background: var(--critical); color: #fff; }
.btn-danger:hover { background: #c02020; }

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

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 5px; }

/* ---- BADGES / STATUS ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-ok       { background: rgba(0,212,170,0.12); color: var(--ok); }
.badge-warning  { background: rgba(245,166,35,0.12); color: var(--warning); }
.badge-problem  { background: rgba(240,96,32,0.12); color: var(--problem); }
.badge-critical { background: rgba(229,53,53,0.15); color: var(--critical); }
.badge-info     { background: rgba(59,127,255,0.12); color: var(--accent); }
.badge-grey     { background: rgba(136,153,181,0.12); color: var(--text2); }

/* Priority badges */
.priority-critical { background: rgba(229,53,53,0.15); color: var(--critical); }
.priority-high     { background: rgba(240,96,32,0.12); color: var(--problem); }
.priority-medium   { background: rgba(245,166,35,0.12); color: var(--warning); }
.priority-low      { background: rgba(59,127,255,0.12); color: var(--accent); }

/* ---- BUILDING CARDS ---- */
.buildings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.building-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: all 0.2s;
}

.building-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(59,127,255,0.15);
}

.building-card-top {
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.building-status-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.building-status-icon.ok       { background: rgba(0,212,170,0.12); }
.building-status-icon.warning  { background: rgba(245,166,35,0.12); }
.building-status-icon.problem  { background: rgba(240,96,32,0.12); }
.building-status-icon.critical { background: rgba(229,53,53,0.12); animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(229,53,53,0.3); }
  50%     { box-shadow: 0 0 0 8px rgba(229,53,53,0); }
}

.building-name { font-weight: 700; font-size: 16px; margin-bottom: 3px; }
.building-address { font-size: 12px; color: var(--text3); }

.building-card-stats {
  display: flex;
  border-top: 1px solid var(--border);
}

.building-card-stat {
  flex: 1;
  padding: 12px 16px;
  text-align: center;
  border-right: 1px solid var(--border);
}
.building-card-stat:last-child { border-right: none; }

.building-card-stat-num {
  font-family: 'Space Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.building-card-stat-label {
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text2);
  margin-bottom: 7px;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], input[type=date],
input[type=time], input[type=year], textarea, select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  padding: 10px 14px;
  transition: border-color 0.15s;
  outline: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,127,255,0.12);
}

select option { background: var(--bg3); }

textarea { resize: vertical; min-height: 90px; }

.form-hint { font-size: 12px; color: var(--text3); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--critical); margin-top: 5px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- ALERTS ---- */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: rgba(0,212,170,0.1); border: 1px solid rgba(0,212,170,0.25); color: var(--ok); }
.alert-error   { background: rgba(229,53,53,0.1); border: 1px solid rgba(229,53,53,0.25); color: var(--critical); }
.alert-warning { background: rgba(245,166,35,0.1); border: 1px solid rgba(245,166,35,0.25); color: var(--warning); }
.alert-info    { background: rgba(59,127,255,0.1); border: 1px solid rgba(59,127,255,0.25); color: var(--accent); }

/* ---- MAP ---- */
#map {
  width: 100%;
  height: calc(100vh - 130px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.map-popup {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 200px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
}

.map-popup h4 { font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.map-popup p  { font-size: 12px; color: var(--text2); margin-bottom: 10px; }

/* ---- MEETING ITEMS ---- */
.meeting-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.meeting-item:last-child { border-bottom: none; }

.item-number {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text3);
  min-width: 24px;
  padding-top: 2px;
}

.item-content { flex: 1; }
.item-text { font-size: 14px; margin-bottom: 4px; }
.item-meta { font-size: 12px; color: var(--text3); }

.item-status-select {
  font-size: 12px;
  padding: 4px 8px;
  width: auto;
}

/* ---- REPORT IMAGE ---- */
.report-image {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 10px 0;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  gap: 2px;
}

.tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text3);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}

.empty-state-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.5; }
.empty-state-title { font-size: 16px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.empty-state-text { font-size: 14px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 199;
  }

  .sidebar-overlay.active { display: block; }

  .main-content { margin-left: 0; }

  .topbar-hamburger { display: flex; }

  .page-body { padding: 16px; }

  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }

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

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

  .topbar { padding: 0 16px; }

  #map { height: 60vh; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ---- UTILITY ---- */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.ml-auto { margin-left: auto; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text3); }
.text-mono { font-family: 'Space Mono', monospace; }
.fw-bold { font-weight: 700; }
.d-none { display: none; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 50%, rgba(59,127,255,0.05) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(0,212,170,0.04) 0%, transparent 40%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  margin: 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 60px; height: 60px;
  background: var(--accent);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 14px;
}

.login-logo-title {
  font-family: 'Space Mono', monospace;
  font-size: 22px;
  font-weight: 700;
}

.login-logo-sub {
  font-size: 13px;
  color: var(--text3);
  margin-top: 4px;
}

/* Sidebar toggle */
input[type=checkbox] { width: auto; }
