/* Plain Silver Client Portal — Styles */

:root {
  --color-primary: #5A6A7A;
  --color-dark: #2C3E50;
  --color-bg: #F5F6F8;
  --color-white: #FFFFFF;
  --color-accent: #4A90D9;
  --color-success: #27AE60;
  --color-danger: #E74C3C;
  --color-warning: #F39C12;
  --color-border: #E0E3E8;
  --color-text: #333333;
  --color-text-light: #7F8C9B;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-stack);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-dark) 0%, var(--color-primary) 100%);
}

.login-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  margin: 16px;
}

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

.login-logo {
  max-width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.login-brand p {
  color: var(--color-text-light);
  font-size: 13px;
  margin-top: 4px;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-stack);
  color: var(--color-text);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--color-white);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-stack);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-white);
  width: 100%;
  padding: 12px;
}

.btn-primary:hover {
  background: #3A7BC8;
}

.btn-primary:disabled {
  background: #8BACC8;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  background: var(--color-bg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.login-error {
  color: var(--color-danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
  display: none; /* toggled by JS */
}

/* ===== Forgot Password ===== */
#forgot-link {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}

#forgot-link a {
  color: var(--color-accent);
  text-decoration: none;
}

#forgot-link a:hover {
  text-decoration: underline;
}

#reset-pwd-div {
  margin-top: 20px;
}

.reset-info {
  text-align: center;
  color: var(--color-text);
  font-size: 14px;
  margin-bottom: 4px;
}

.reset-info-sub {
  color: var(--color-text-light);
  font-size: 13px;
  margin-bottom: 20px;
}

.reset-buttons {
  display: flex;
  gap: 12px;
}

.reset-buttons .btn {
  flex: 1;
}

#reset-status {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--color-text);
}

/* ===== App Shell ===== */
.app-shell {
  display: none;
  min-height: 100vh;
}

.app-shell.active {
  display: flex;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--color-dark);
  color: var(--color-white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  max-width: 160px;
  height: auto;
  display: block;
}

.sidebar-brand p {
  font-size: 11px;
  color: #8899AA;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: #A0B0C0;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a.active {
  color: var(--color-white);
  background: rgba(255, 255, 255, 0.08);
  border-left-color: var(--color-accent);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
}

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

.sidebar-footer .client-info {
  font-size: 12px;
  color: #8899AA;
  margin-bottom: 8px;
}

.sidebar-footer .client-info strong {
  display: block;
  color: #C0CDD8;
  font-size: 13px;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.08);
  color: #A0B0C0;
  border: none;
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-stack);
}

.btn-logout:hover {
  background: rgba(231, 76, 60, 0.2);
  color: #E74C3C;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 0;
  min-height: 100vh;
}

.top-bar {
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-dark);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--color-primary);
  cursor: pointer;
  padding: 4px;
}

.page-content {
  padding: 32px;
}

/* ===== Dashboard KPI Banner ===== */
.kpi-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: linear-gradient(135deg, var(--color-dark) 0%, var(--color-primary) 100%);
  border-radius: var(--radius);
  padding: 22px 24px;
  color: var(--color-white);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #A0B0C0;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.15;
}

.kpi-value-sm {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
}

.kpi-sub {
  font-size: 13px;
  margin-top: 6px;
  color: #A0B0C0;
}

.kpi-sub.up {
  color: #6FCF97;
}

.kpi-sub.down {
  color: #EB9B9B;
}

/* ===== Dashboard Map ===== */
.dashboard-map-container {
  position: relative;
  z-index: 1;
  height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
  background: #E8ECEF;
}

.dashboard-map-container.hidden {
  display: none !important;
}

.map-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  color: var(--color-text-light);
  z-index: 500;
  background: rgba(255,255,255,0.85);
  padding: 8px 18px;
  border-radius: 6px;
  pointer-events: none;
}

.map-loading.hidden {
  display: none !important;
}

/* Leaflet popup overrides */
.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
  box-shadow: 0 4px 14px rgba(0,0,0,0.13) !important;
  font-family: var(--font-stack) !important;
}

.leaflet-popup-content {
  margin: 14px 16px !important;
  font-size: 13px !important;
  line-height: 1.5 !important;
}

.leaflet-popup-content .popup-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-dark);
  margin-bottom: 2px;
}

.leaflet-popup-content .popup-address {
  color: var(--color-text-light);
  font-size: 12px;
  margin-bottom: 8px;
}

.leaflet-popup-content .popup-revenue {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-dark);
  margin-bottom: 4px;
}

.leaflet-popup-content .popup-trend {
  font-size: 12px;
  margin-bottom: 8px;
}

.leaflet-popup-content .popup-link {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  cursor: pointer;
}

.leaflet-popup-content .popup-link:hover {
  text-decoration: underline;
}

.location-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.location-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.location-card:hover {
  box-shadow: var(--shadow-elevated);
  transform: translateY(-1px);
}

.location-card .loc-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 4px;
}

.location-card .loc-address {
  font-size: 13px;
  color: var(--color-text-light);
  margin-bottom: 16px;
}

.location-card .loc-revenue {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-dark);
}

.location-card .loc-comparison {
  font-size: 13px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.location-card .loc-comparison.up {
  color: var(--color-success);
}

.location-card .loc-comparison.down {
  color: var(--color-danger);
}

.location-card .loc-meta {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-light);
}

/* ===== Reports ===== */
.report-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.report-controls label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
}

.report-controls select {
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-white);
  min-width: 160px;
}

.report-controls select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.data-table-wrapper {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.table-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-dark);
}

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

.data-table th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-light);
  background: #FAFBFC;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 14px 24px;
  font-size: 14px;
  border-bottom: 1px solid #F0F2F4;
}

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

.data-table tr:hover td {
  background: #FAFBFC;
}

.data-table .total-row td {
  font-weight: 700;
  background: #F5F6F8;
  border-top: 2px solid var(--color-border);
  color: var(--color-dark);
}

.data-table .align-right {
  text-align: right;
}

/* ===== Chart Section ===== */
.chart-container {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 24px;
}

.chart-container h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 16px;
}

.chart-container canvas {
  width: 100%;
  height: 320px;
}

/* ===== Payouts ===== */
.payout-list {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.payout-row {
  display: flex;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #F0F2F4;
  cursor: pointer;
  transition: background 0.15s;
}

.payout-row:last-child {
  border-bottom: none;
}

.payout-row:hover {
  background: #FAFBFC;
}

.payout-row .payout-period {
  flex: 1;
  font-weight: 600;
  color: var(--color-dark);
}

.payout-row .payout-amount {
  font-weight: 700;
  font-size: 16px;
  color: var(--color-dark);
  margin-right: 20px;
}

.payout-row .statement-name {
  font-weight: 600;
  color: var(--color-dark);
  font-size: 14px;
}

.payout-row .statement-desc {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.payout-row .statement-info {
  flex: 1;
  min-width: 0;
}

.payout-row .statement-dates {
  font-size: 12px;
  color: var(--color-text-light);
  margin-top: 2px;
}

.statement-notes {
  padding: 8px 16px 4px;
  font-size: 13px;
  color: var(--color-text-light);
  font-style: italic;
}

.statement-export {
  padding: 10px 16px 6px;
  text-align: right;
}

.statement-total-row td {
  font-weight: 700;
  background: #F0F2F4;
  border-top: 2px solid var(--color-border);
}

.payout-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.payout-status.paid {
  background: #E8F5E9;
  color: var(--color-success);
}

.payout-status.pending {
  background: #FFF3E0;
  color: var(--color-warning);
}

.payout-date {
  font-size: 13px;
  color: var(--color-text-light);
  margin-left: 16px;
  min-width: 100px;
  text-align: right;
}

.payout-toggle {
  margin-left: 12px;
  color: var(--color-text-light);
  transition: transform 0.2s;
  font-size: 12px;
}

.payout-toggle.expanded {
  transform: rotate(180deg);
}

.payout-detail {
  display: none;
  padding: 0 24px 16px;
  background: #FAFBFC;
}

.payout-detail.open {
  display: block;
}

.payout-detail table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.payout-detail-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.payout-detail th {
  text-align: left;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-light);
  border-bottom: 1px solid var(--color-border);
}

.payout-detail td {
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid #ECEEF0;
}

.payout-detail tr:last-child td {
  border-bottom: none;
}

/* ===== Session Expired Overlay ===== */
.session-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(44, 62, 80, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.session-overlay.active {
  display: flex;
}

.session-overlay-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  padding: 40px;
  text-align: center;
  max-width: 380px;
  width: 90%;
}

.session-overlay-card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 12px;
}

.session-overlay-card p {
  font-size: 14px;
  color: var(--color-text-light);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ===== Search ===== */
.search-wrap {
  margin-bottom: 20px;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

/* ===== Sortable Headers ===== */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th.sortable:hover {
  color: var(--color-accent);
}

.data-table th.sortable .sort-arrow {
  font-size: 10px;
  margin-left: 3px;
  color: var(--color-text-light);
}

.data-table th.sortable.sort-asc .sort-arrow::after {
  content: '\25B2';
}

.data-table th.sortable.sort-desc .sort-arrow::after {
  content: '\25BC';
}

/* ===== Manage Payouts ===== */
.manage-payouts-card {
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 32px;
  max-width: 500px;
}

.manage-payouts-card h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 12px;
}

.manage-payouts-card p {
  color: var(--color-text-light);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.manage-payouts-card .btn-primary {
  width: auto;
  padding: 12px 28px;
}

#stripe-connect-status {
  margin-top: 16px;
  font-size: 14px;
  color: var(--color-danger);
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--color-text-light);
}

.text-success {
  color: var(--color-success);
}

.text-danger {
  color: var(--color-danger);
}

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

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

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

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

  .mobile-menu-btn {
    display: block;
  }

  .page-content {
    padding: 24px 16px;
  }

  .top-bar {
    padding: 12px 16px;
  }

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

  .dashboard-map-container {
    height: 280px;
  }

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

  .data-table th,
  .data-table td {
    padding: 10px 14px;
  }

  .payout-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .payout-date {
    width: 100%;
    text-align: left;
    margin-left: 0;
  }
}

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

  .kpi-value {
    font-size: 26px;
  }

  .dashboard-map-container {
    height: 220px;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}

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

/* Print styles */
@media print {
  .sidebar, .top-bar, .report-controls .btn, .dashboard-map-container {
    display: none !important;
  }

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

  .data-table-wrapper {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  /* Payouts page: print every location's detail table, expanded or not */
  #locpay-list .payout-detail {
    display: block !important;
  }

  #locpay-list .payout-toggle {
    display: none !important;
  }
}
