/*
  Solar EPC CRM Admin Panel
  Frontend only dashboard theme using Bootstrap 5
*/

:root {
  --solar-blue: #1d4ed8;
  --solar-green: #16803c;
  --solar-yellow: #f6c344;
  --solar-dark: #111827;
  --solar-dark-2: #182235;
  --solar-muted: #6b7280;
  --solar-bg: #f5f7fb;
  --solar-card: #ffffff;
  --border: #e5e7eb;
  --shadow: 0 12px 35px rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 8px 18px rgba(17, 24, 39, 0.06);
  --radius: 18px;
  --sidebar-width: 280px;
  --sidebar-collapsed: 86px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--solar-bg);
  color: #172033;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #0f172a 0%, #111827 50%, #0b1220 100%);
  color: #fff;
  z-index: 1040;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow-y: auto;
  box-shadow: 8px 0 30px rgba(15, 23, 42, 0.15);
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 20px;
}

.sidebar-brand {
  min-height: 78px;
  padding: 18px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--solar-green), var(--solar-yellow));
  color: #fff;
  box-shadow: 0 10px 20px rgba(22, 128, 60, 0.22);
}

.brand-icon i {
  font-size: 21px;
}

.brand-text span {
  display: block;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-text small {
  color: #cbd5e1;
  font-size: 12px;
}

.sidebar-menu {
  padding: 14px 12px 28px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin: 4px 0;
  color: #dbe4f0;
  border-radius: 14px;
  text-decoration: none;
  transition: 0.2s ease;
  position: relative;
}

.menu-link i {
  width: 22px;
  min-width: 22px;
  text-align: center;
  font-size: 16px;
}

.menu-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-link:hover,
.menu-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateX(3px);
}

.menu-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  width: 4px;
  height: 26px;
  border-radius: 20px;
  background: var(--solar-yellow);
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

.sidebar-collapsed .brand-text,
.sidebar-collapsed .menu-link span {
  display: none;
}

.sidebar-collapsed .sidebar-brand,
.sidebar-collapsed .menu-link {
  justify-content: center;
}

.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1030;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: all;
}

/* Main */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: 78px;
  background: rgba(245, 247, 251, 0.88);
  backdrop-filter: blur(14px);
  padding: 14px 24px;
  border-bottom: 1px solid rgba(229, 231, 235, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-heading {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  color: #111827;
}

.page-subtitle {
  color: var(--solar-muted);
  font-size: 13px;
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1f2937;
  transition: 0.2s ease;
}

.icon-btn:hover,
.profile-btn:hover {
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.search-box,
.input-icon {
  position: relative;
  align-items: center;
}

.search-box {
  width: 330px;
  height: 42px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  padding: 0 13px;
  gap: 10px;
}

.search-box input,
.input-icon input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
  color: #111827;
}

.search-box i,
.input-icon i {
  color: #9ca3af;
}

.notification-dot {
  position: absolute;
  top: 10px;
  right: 11px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
}

.profile-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 16px;
  height: 42px;
  padding: 5px 10px 5px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #111827;
  transition: 0.2s ease;
}

.profile-btn img {
  width: 31px;
  height: 31px;
  border-radius: 12px;
}

.content-wrap {
  padding: 24px;
}

.page-section {
  display: none;
  animation: fadeIn 0.25s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.panel-card,
.stat-card,
.mini-card,
.pipeline-card,
.report-card {
  background: var(--solar-card);
  border: 1px solid rgba(229, 231, 235, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.panel-card {
  padding: 20px;
}

.stat-card {
  min-height: 134px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: 0.22s ease;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -32px;
  bottom: -32px;
  width: 110px;
  height: 110px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.stat-card:hover,
.panel-card:hover,
.report-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-card p,
.mini-card p,
.pipeline-card p {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 600;
}

.stat-card h3 {
  margin: 0;
  font-size: 25px;
  font-weight: 800;
  color: #fff;
}

.stat-card span {
  display: block;
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.stat-card i {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 20px;
  z-index: 1;
}

.stat-blue { background: linear-gradient(135deg, #2563eb, #1e40af); }
.stat-green { background: linear-gradient(135deg, #16a34a, #166534); }
.stat-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-red { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.stat-cyan { background: linear-gradient(135deg, #06b6d4, #0e7490); }
.stat-orange { background: linear-gradient(135deg, #f97316, #c2410c); }
.stat-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-darkblue { background: linear-gradient(135deg, #334155, #0f172a); }

.card-header-clean {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.card-header-clean h5 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #111827;
}

.card-header-clean p {
  margin: 4px 0 0;
  color: var(--solar-muted);
  font-size: 13px;
}

.mini-card {
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  height: 100%;
}

.mini-card p,
.pipeline-card p {
  color: var(--solar-muted);
}

.mini-card h4,
.pipeline-card h3 {
  margin: 0;
  font-weight: 800;
  color: #111827;
}

.mini-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 18px;
}

.mini-icon.green { background: #dcfce7; color: #16803c; }
.mini-icon.red { background: #fee2e2; color: #dc2626; }
.mini-icon.yellow { background: #fef3c7; color: #d97706; }
.mini-icon.blue { background: #dbeafe; color: #1d4ed8; }

.pipeline-card {
  padding: 18px;
  border-left: 4px solid var(--solar-green);
  transition: 0.2s ease;
}

.pipeline-card:hover {
  transform: translateY(-2px);
}

/* Tables and filters */
.toolbar-row,
.filter-grid {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar-row .input-icon {
  flex: 1 1 280px;
}

.input-icon {
  display: flex;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 13px;
  background: #fff;
  gap: 10px;
}

.toolbar-row .form-select,
.toolbar-row .form-control,
.filter-grid .form-control,
.filter-grid .form-select {
  min-height: 42px;
  border-radius: 14px;
  border-color: var(--border);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.table {
  margin-bottom: 0;
}

.table thead th {
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  color: #263244;
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
}

.table-hover tbody tr:hover {
  background: #f8fbff;
}

.badge-soft {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.badge-present,
.badge-available,
.badge-income,
.badge-completed,
.badge-won,
.badge-active,
.badge-accepted,
.badge-sent {
  background: #dcfce7;
  color: #166534;
}

.badge-absent,
.badge-out,
.badge-expense,
.badge-failed,
.badge-lost,
.badge-inactive,
.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge-late,
.badge-low,
.badge-pending,
.badge-follow,
.badge-draft,
.badge-hold {
  background: #fef3c7;
  color: #92400e;
}

.badge-half,
.badge-process,
.badge-site,
.badge-new,
.badge-survey,
.badge-installation,
.badge-partial {
  background: #dbeafe;
  color: #1e40af;
}

.btn-solar {
  background: linear-gradient(135deg, var(--solar-green), #0f9f59);
  color: #fff;
  border: 0;
  border-radius: 13px;
  box-shadow: 0 8px 18px rgba(22, 128, 60, 0.18);
}

.btn-solar:hover {
  background: linear-gradient(135deg, #106c34, #0d8e4e);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-solar {
  border: 1px solid rgba(22, 128, 60, 0.45);
  color: var(--solar-green);
  border-radius: 13px;
}

.btn-outline-solar:hover {
  background: var(--solar-green);
  color: #fff;
}

.action-btns {
  display: inline-flex;
  gap: 6px;
}

.action-btns .btn {
  width: 31px;
  height: 31px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
}

/* Dashboard activity */
.activity-list {
  display: grid;
  gap: 14px;
}

.activity-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fbfdff;
}

.activity-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.activity-item strong {
  font-size: 14px;
}

.activity-item p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--solar-muted);
}

/* File tracking */
.upload-box {
  border: 1.5px dashed rgba(29, 78, 216, 0.28);
  border-radius: 18px;
  padding: 34px 18px;
  text-align: center;
  background: linear-gradient(180deg, #f8fbff, #fff);
}

.upload-box.compact {
  padding: 24px 18px;
}

.upload-box i {
  font-size: 38px;
  color: var(--solar-blue);
  margin-bottom: 12px;
}

.upload-box h5 {
  font-weight: 800;
  margin-bottom: 6px;
}

.upload-box p {
  color: var(--solar-muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 16px;
}

.timeline-step {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  position: relative;
}

.timeline-step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 22px;
  width: 2px;
  height: calc(100% + 4px);
  background: #dbe3ef;
}

.timeline-step span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px #cbd5e1;
  z-index: 1;
}

.timeline-step.done span {
  background: var(--solar-green);
  box-shadow: 0 0 0 1px var(--solar-green);
}

.timeline-step.current span {
  background: var(--solar-yellow);
  box-shadow: 0 0 0 1px var(--solar-yellow);
}

.timeline-step p {
  margin: 0;
  color: #374151;
  font-size: 13px;
}

.document-grid,
.modal-permissions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.detail-box span {
  color: var(--solar-muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

/* Roles */
.permission-list {
  display: grid;
  gap: 10px;
}

.permission-list label,
.modal-permissions label {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdff;
  color: #374151;
  font-size: 14px;
}

.permission-list input,
.modal-permissions input {
  accent-color: var(--solar-green);
  margin-right: 8px;
}

/* Quotation */
.quote-form .form-control,
.quote-form .form-select,
.modal .form-control,
.modal .form-select,
#settings .form-control,
#settings .form-select {
  border-radius: 13px;
  border-color: var(--border);
}

.quote-total-box {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  border: 1px solid rgba(29, 78, 216, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quote-total-box span {
  color: var(--solar-muted);
  font-weight: 700;
}

.quote-total-box strong {
  color: var(--solar-green);
  font-size: 22px;
}

.quotation-preview {
  background: #fff;
}

.quote-preview-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  border-bottom: 2px solid #eef2f7;
  padding-bottom: 15px;
}

.logo-placeholder {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--solar-green);
  font-weight: 900;
  font-size: 20px;
}

.logo-placeholder i {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #dcfce7;
  border-radius: 15px;
}

.quotation-preview h6 {
  font-weight: 800;
}

.quotation-preview p {
  color: #4b5563;
  font-size: 13px;
}

.quote-table th {
  background: #f8fafc;
}

.quote-summary {
  max-width: 340px;
  display: grid;
  gap: 8px;
}

.quote-summary p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eef2f7;
  padding-bottom: 8px;
}

.quote-summary .grand {
  background: #ecfdf5;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #bbf7d0;
  color: #14532d;
  font-size: 16px;
}

.terms-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.signature-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 30px;
}

.signature-row span {
  width: 45%;
  border-top: 1px solid #9ca3af;
  padding-top: 8px;
  text-align: center;
  color: var(--solar-muted);
  font-size: 13px;
}

/* Reports and profile */
.report-card {
  padding: 24px;
  min-height: 236px;
  transition: 0.2s ease;
}

.report-card i {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #eff6ff;
  color: var(--solar-blue);
  font-size: 20px;
  margin-bottom: 15px;
}

.report-card h5 {
  font-weight: 800;
  margin-bottom: 8px;
}

.report-card p {
  color: var(--solar-muted);
  font-size: 14px;
  min-height: 62px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.profile-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.profile-card h6 {
  font-weight: 800;
  margin-bottom: 8px;
}

.profile-card p {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
}

.theme-dots {
  display: flex;
  gap: 10px;
}

.theme-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}

.theme-dot.blue { background: var(--solar-blue); }
.theme-dot.green { background: var(--solar-green); }
.theme-dot.yellow { background: var(--solar-yellow); }
.theme-dot.active { box-shadow: 0 0 0 2px var(--solar-dark); }

/* Responsive */
@media (max-width: 1199.98px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .main-content,
  .sidebar-collapsed .main-content {
    margin-left: 0;
  }

  .topbar {
    padding: 13px 16px;
  }

  .content-wrap {
    padding: 18px;
  }
}

@media (max-width: 767.98px) {
  .topbar {
    align-items: flex-start;
  }

  .page-heading {
    font-size: 18px;
  }

  .page-subtitle {
    display: none;
  }

  .toolbar-row,
  .filter-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar-row .input-icon,
  .toolbar-row .form-select,
  .toolbar-row .form-control,
  .toolbar-row .btn,
  .filter-grid .form-control,
  .filter-grid .form-select {
    width: 100%;
  }

  .panel-card {
    padding: 16px;
  }

  .stat-card h3 {
    font-size: 21px;
  }

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

  .signature-row {
    flex-direction: column;
  }

  .signature-row span {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  .topbar-actions {
    gap: 6px;
  }

  .profile-btn {
    width: 42px;
    padding: 5px;
    justify-content: center;
  }

  .profile-btn::after {
    display: none;
  }
}
