/* Wadadli Solar Projects Portal — Corporate Style */

:root {
  --navy: #1e293b;
  --navy-dark: #0f172a;
  --navy-mid: #334155;
  --blue: #1d4ed8;
  --blue-light: #3b82f6;
  --blue-pale: #eff6ff;
  --green: #059669;
  --green-pale: #ecfdf5;
  --amber: #d97706;
  --amber-pale: #fffbeb;
  --red: #dc2626;
  --red-pale: #fef2f2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --text: #1e293b;
  --text-secondary: #64748b;
  --sidebar-width: 240px;
  --header-height: 60px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: var(--sidebar-width);
  background: var(--navy-dark);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

#page-content { padding: 28px 28px; flex: 1; }

/* ── Sidebar ── */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f8fafc;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--gray-400);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 3px;
}

.sidebar-section {
  padding: 16px 0 8px;
}

.sidebar-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray-500);
  padding: 0 16px 8px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-nav a:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,0.05);
  border-left-color: transparent;
}

.sidebar-nav a.active {
  color: #ffffff;
  background: rgba(29,78,216,0.2);
  border-left-color: var(--blue-light);
}

.sidebar-nav a .nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

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

.sidebar-user .avatar {
  width: 30px; height: 30px;
  background: var(--blue);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 12px; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 10px; color: var(--gray-500); }

/* ── Topbar ── */
.topbar-title { font-size: 15px; font-weight: 600; color: var(--navy); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.btn-logout {
  font-size: 12px;
  color: var(--gray-500);
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* ── Cards & Panels ── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-600);
}

.card-body { padding: 20px; }

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

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
}

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

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 4px;
}

.stat-card.accent { border-left: 3px solid var(--blue); }
.stat-card.danger { border-left: 3px solid var(--red); }
.stat-card.success { border-left: 3px solid var(--green); }
.stat-card.warning { border-left: 3px solid var(--amber); }

/* ── Tables ── */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: var(--gray-50); }

.data-table .link-cell a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.data-table .link-cell a:hover { text-decoration: underline; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-active    { background: var(--blue-pale); color: var(--blue); }
.badge-complete  { background: var(--green-pale); color: var(--green); }
.badge-on-hold   { background: var(--amber-pale); color: var(--amber); }
.badge-pending   { background: var(--gray-100); color: var(--gray-600); }
.badge-critical  { background: #fef2f2; color: var(--red); }
.badge-major     { background: var(--amber-pale); color: var(--amber); }
.badge-minor     { background: var(--gray-100); color: var(--gray-600); }
.badge-draft     { background: var(--gray-100); color: var(--gray-600); }
.badge-in-review { background: var(--amber-pale); color: var(--amber); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: #1e40af; }

.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Tabs ── */
.tabs-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,78,216,0.08); }

select.form-control { cursor: pointer; }

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

/* ── Login Page ── */
#login-page {
  min-height: 100vh;
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  background: white;
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
}

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

.login-logo .company { font-size: 18px; font-weight: 800; color: var(--navy-dark); letter-spacing: -0.02em; }
.login-logo .tagline { font-size: 11px; color: var(--gray-400); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.login-logo .portal-label {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 12px;
  background: var(--navy-dark);
  color: white;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
}

.login-title { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 24px; text-align: center; }

.login-error {
  background: var(--red-pale);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-error.show { display: block; }

.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--navy-dark);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.btn-login:hover { background: var(--blue); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Page Headers ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy-dark);
  line-height: 1.2;
}

.page-header .breadcrumb {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 3px;
}

.page-header .breadcrumb a { color: var(--blue); text-decoration: none; }
.page-header .breadcrumb a:hover { text-decoration: underline; }

/* ── Project Status Bar ── */
.project-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray-400); }
.meta-value { font-size: 13px; font-weight: 500; color: var(--navy); }

/* ── Photo Grid ── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.photo-item {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.photo-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.photo-item img {
  width: 100%; height: 140px;
  object-fit: cover; display: block;
}

.photo-item .photo-caption {
  padding: 8px;
  font-size: 11px;
  color: var(--gray-600);
  background: white;
}

/* ── File List ── */
.file-list { display: flex; flex-direction: column; gap: 8px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  transition: border-color 0.15s;
}

.file-item:hover { border-color: var(--blue); }

.file-icon {
  width: 36px; height: 36px;
  border-radius: 6px;
  background: var(--blue-pale);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.file-icon svg { width: 18px; height: 18px; color: var(--blue); }

.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 11px; color: var(--gray-400); margin-top: 1px; }

.file-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Findings ── */
.finding-card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.finding-card.critical { border-left: 4px solid var(--red); }
.finding-card.major { border-left: 4px solid var(--amber); }
.finding-card.minor { border-left: 4px solid var(--blue-light); }
.finding-card.observation { border-left: 4px solid var(--gray-300); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  cursor: pointer;
}

.finding-title { font-size: 13px; font-weight: 600; color: var(--navy); flex: 1; }
.finding-body { padding: 12px 16px; background: var(--gray-50); border-top: 1px solid var(--gray-200); display: none; }
.finding-body.open { display: block; }
.finding-body p { font-size: 13px; color: var(--gray-700); line-height: 1.6; }
.finding-body .rec { margin-top: 10px; padding: 10px 12px; background: var(--blue-pale); border-radius: 6px; font-size: 12px; color: var(--blue); }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--blue);
  background: var(--blue-pale);
}

.upload-zone .upload-icon { color: var(--gray-400); margin-bottom: 12px; }
.upload-zone h3 { font-size: 14px; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.upload-zone p { font-size: 12px; color: var(--gray-500); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
  display: none;
}

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

.modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--navy); }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 20px; line-height: 1;
  padding: 0; transition: color 0.15s;
}

.modal-close:hover { color: var(--navy); }

.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Lightbox ── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 100%; max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  color: white; font-size: 32px; cursor: pointer;
  background: none; border: none; line-height: 1;
  opacity: 0.8;
}

.lightbox-close:hover { opacity: 1; }

/* ── Empty States ── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--gray-400);
}

.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.4; }
.empty-state p { font-size: 13px; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: var(--green-pale); color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: var(--red-pale); color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: var(--blue-pale); color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Utility ── */
.hidden { display: none !important; }
.text-muted { color: var(--gray-400); }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ── Loading ── */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; gap: 12px; color: var(--gray-400);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  #sidebar {
    transform: translateX(-100%);
    width: 240px;
    transition: transform 0.25s ease;
  }

  #sidebar.open { transform: translateX(0); --sidebar-width: 240px; }

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

  #page-content { padding: 16px; }

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

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

  #topbar { padding: 0 16px; }

  .menu-toggle {
    display: flex !important;
    align-items: center; justify-content: center;
    background: none; border: none; cursor: pointer;
    padding: 4px; color: var(--gray-600);
  }
}

.menu-toggle { display: none; }

/* ── Print ── */
@media print {
  #sidebar, #topbar { display: none; }
  #main-content { margin-left: 0; }
  #page-content { padding: 0; }
  .btn, .upload-zone { display: none; }
}
