/* ============================================================
   Almonte Plumbing — dashboard.css
   Shared styles for all authenticated dashboard pages.
   ============================================================ */

/* ── Layout shell ── */
.dash-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo img {
  width: 120px;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--color-primary);
  font-family: 'Barlow', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--color-text);
  background: rgba(137,183,238,0.06);
  border-left-color: var(--color-primary);
}

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

.sidebar-nav a:hover svg,
.sidebar-nav a.active svg {
  opacity: 1;
}

.sidebar-section-label {
  padding: 1rem 1.25rem 0.25rem;
  font-family: 'Barlow', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(138,138,138,0.5);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer a {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.15s;
}

.sidebar-footer a:hover { color: var(--color-error); }

/* ── Main content ── */
.dash-main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dash-topbar {
  background: var(--color-surface);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.dash-topbar-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.dash-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-content {
  padding: 2rem;
  flex: 1;
}

/* ── Hamburger toggle (mobile) ── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.25rem;
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
}

.stat-label {
  font-family: 'Barlow', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 2.25rem;
  line-height: 1;
  color: var(--color-text);
}

.stat-card.highlight .stat-value {
  color: var(--color-primary);
}

/* ── Panel / card ── */
.panel {
  background: var(--color-surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-title {
  font-family: 'Barlow', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.panel-body { padding: 1.5rem; }

/* ── Data table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  font-family: 'Barlow', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.75rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}

.data-table td {
  padding: 0.875rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

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

.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Team profile thumbnails (Portal Users view) ── */
.user-photo-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.user-photo-thumb-empty {
  border: 1px dashed rgba(255,255,255,0.15);
}

.data-table .muted { color: var(--color-text-muted); font-size: 0.82rem; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.65em;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Barlow', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.badge-owner    { background: rgba(137,183,238,0.15); color: var(--color-primary); }
.badge-employee { background: rgba(76,175,130,0.15);  color: #5DC99A; }
.badge-customer { background: rgba(255,255,255,0.08); color: var(--color-text-muted); }

.badge-pending     { background: rgba(255,193,7,0.12);  color: #FFC107; }
.badge-scheduled   { background: rgba(137,183,238,0.15); color: var(--color-primary); }
.badge-in_progress { background: rgba(103,140,238,0.15); color: #8A9EF0; }
.badge-completed   { background: rgba(76,175,130,0.15);  color: #5DC99A; }
.badge-cancelled   { background: rgba(224,92,92,0.12);   color: #E87F7F; }

.badge-urgent { background: rgba(224,92,92,0.12); color: #E87F7F; }
.badge-normal { background: rgba(255,255,255,0.07); color: var(--color-text-muted); }
.badge-low    { background: rgba(76,175,130,0.1);  color: #4CAF82; }

/* ── Forms inside dashboard ── */
.dash-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dash-form .form-group { margin-bottom: 1rem; }

.dash-form label {
  display: block;
  font-family: 'Barlow', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.dash-form input,
.dash-form select,
.dash-form textarea {
  width: 100%;
  padding: 0.65rem 0.875rem;
  background: var(--color-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.dash-form input:focus,
.dash-form select:focus,
.dash-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.dash-form select option { background: var(--color-surface); }
.dash-form textarea { resize: vertical; min-height: 100px; }

/* ── Inline action links ── */
.action-link {
  font-size: 0.82rem;
  color: var(--color-primary);
  transition: opacity 0.15s;
}
.action-link:hover { opacity: 0.75; }
.action-link.danger { color: var(--color-error); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
}
.empty-state p { margin-top: 0.5rem; font-size: 0.9rem; }

/* ── Alert / flash ── */
.dash-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}
.dash-alert-success { background: rgba(76,175,130,0.12); border: 1px solid rgba(76,175,130,0.3); color: #5DC99A; }
.dash-alert-error   { background: rgba(224,92,92,0.12);  border: 1px solid rgba(224,92,92,0.3);  color: #E87F7F; }

/* ── Mobile sidebar ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .dash-main {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: flex;
  }
  .dash-topbar {
    padding: 0 1rem;
  }
  .dash-content {
    padding: 1.25rem 1rem;
  }
  .dash-form .form-row {
    grid-template-columns: 1fr;
  }
  .data-table th,
  .data-table td {
    padding: 0.75rem 1rem;
  }
}

/* ── Sidebar overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ── Services management view ── */

.svc-cat-block {
  border-top: 1px solid rgba(255,255,255,0.06);
}

.svc-cat-block:first-of-type {
  border-top: none;
}

.svc-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem var(--space-md);
  background: var(--color-surface-alt);
}

.svc-cat-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.svc-cat-name {
  font-family: "Barlow", sans-serif;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-white);
}

.svc-cat-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

/* Photo grid in service edit view */
.svc-dash-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.svc-dash-photo-item {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--color-bg);
  cursor: grab;
  border: 2px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
}

.svc-dash-photo-item.is-main {
  border-color: var(--color-primary);
}

.svc-dash-photo-item.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.svc-dash-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.svc-photo-main-badge {
  position: absolute;
  top: 0.35rem;
  left: 0.35rem;
  background: var(--color-primary);
  color: var(--color-bg);
  font-family: 'Barlow', sans-serif;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  z-index: 1;
}

.svc-photo-actions {
  position: absolute;
  bottom: 0.35rem;
  left: 0.35rem;
  right: 0.35rem;
}

.svc-photo-setmain {
  width: 100%;
  background: rgba(0,0,0,0.7);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.4rem;
  font-family: 'Barlow', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.svc-photo-setmain:hover {
  background: var(--color-primary);
  color: var(--color-bg);
}

.svc-photo-delete {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  background: rgba(0,0,0,0.7);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-pill);
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.svc-photo-delete:hover {
  background: var(--color-error);
}

/* ── Image Crop Modal ─────────────────────────────────────────────────────── */
#img-crop-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.88);
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}

#img-crop-modal.open {
  display: flex;
}

.crop-modal-inner {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  width: 100%;
  max-width: 720px;
  box-shadow: var(--shadow-md);
}

.crop-modal-header {
  margin-bottom: var(--space-md);
}

.crop-modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-white);
  margin: 0 0 0.2rem;
}

.crop-modal-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.crop-stage-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.crop-frame {
  position: relative;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-bg);
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 2px solid var(--color-primary);
}

.crop-frame:active {
  cursor: grabbing;
}

#crop-img {
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-counter {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  min-height: 1.4em;
  margin-bottom: var(--space-sm);
}

.crop-modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

@media (max-width: 400px) {
  .crop-modal-inner {
    padding: var(--space-sm);
  }
  .crop-modal-actions {
    flex-direction: column-reverse;
  }
  .crop-modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
}
