/**
 * Webcross Workspace Platform - Modern Dashboard Design System
 */

:root {
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #1e293b;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  
  --border-subtle: #e2e8f0;
  --border-sidebar: #1e293b;
  
  --cyan-primary: #0284c7;
  --cyan-dark: #0369a1;
  --cyan-soft: #e0f2fe;
  
  --amber-primary: #d97706;
  --amber-dark: #b45309;
  --amber-soft: #fef3c7;
  
  --emerald-primary: #059669;
  --emerald-soft: #d1fae5;
  
  --rose-primary: #e11d48;
  --rose-soft: #ffe4e6;
  
  --purple-primary: #7c3aed;
  --purple-soft: #f3e8ff;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

/* Impersonation Banner */
.impersonation-bar {
  background: linear-gradient(90deg, #d97706 0%, #b45309 100%);
  color: #ffffff;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  font-weight: 600;
  font-size: 0.85rem;
  box-shadow: 0 2px 10px rgba(217, 119, 6, 0.3);
}

.impersonation-bar .btn-exit {
  background: #ffffff;
  color: #b45309;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.impersonation-bar .btn-exit:hover {
  background: #fef3c7;
}

body.has-impersonation-bar {
  padding-top: 40px;
}

/* App Wrapper */
.app-wrapper {
  display: flex;
  width: 100%;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  height: 64px;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  width: 100%;
  transition: opacity 0.2s ease;
}

.sidebar-brand-link:hover {
  opacity: 0.92;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  flex-shrink: 0;
  padding: 2px;
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: block;
}

.sidebar-brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.sidebar-brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.sidebar-brand-sub {
  font-size: 0.62rem;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 1.25rem 0.85rem;
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.75rem 0.65rem 0.35rem 0.65rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background-color: #0284c7;
  color: #ffffff;
  font-weight: 600;
}

.nav-item.active-orange {
  background-color: #ea580c;
  color: #ffffff;
}

.nav-item svg {
  flex-shrink: 0;
}

.nav-item .nav-count-badge {
  margin-left: auto;
  background: #334155;
  color: #f1f5f9;
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.nav-item.active .nav-count-badge {
  background: #ffffff;
  color: #0284c7;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.5);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #1e293b;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-user-role {
  color: #64748b;
  font-size: 0.75rem;
  text-transform: capitalize;
}

/* Main Content Area */
.app-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.app-topbar {
  height: 64px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.business-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
}

.business-switcher select {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  outline: none;
  cursor: pointer;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-link-external {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-link-external:hover {
  color: var(--cyan-primary);
}

/* Page Body Container */
.page-content {
  padding: 2rem;
  flex-grow: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Flash Alerts */
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background-color: var(--emerald-soft);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background-color: var(--rose-soft);
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.alert-warning {
  background-color: var(--amber-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background-color: var(--cyan-soft);
  color: #075985;
  border: 1px solid #bae6fd;
}

/* Stat Grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.stat-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
}

.stat-card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.75rem;
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.card-body {
  padding: 1.5rem;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: #334155;
  vertical-align: middle;
}

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

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

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-primary { background: #e0f2fe; color: #0369a1; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #ffe4e6; color: #9f1239; }
.badge-purple  { background: #f3e8ff; color: #6b21a8; }
.badge-secondary{ background: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--cyan-primary);
  color: #ffffff;
  border-color: var(--cyan-primary);
}

.btn-primary:hover {
  background-color: var(--cyan-dark);
}

.btn-secondary {
  background-color: #ffffff;
  color: #334155;
  border-color: #cbd5e1;
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.btn-danger {
  background-color: var(--rose-primary);
  color: #ffffff;
  border-color: var(--rose-primary);
}

.btn-success {
  background-color: var(--emerald-primary);
  color: #ffffff;
  border-color: var(--emerald-primary);
}

.btn-orange {
  background-color: #ea580c;
  color: #ffffff;
  border-color: #ea580c;
}

.btn-orange:hover {
  background-color: #c2410c;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: #334155;
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: #0f172a;
  background-color: #ffffff;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--cyan-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Invoice Print Styles */
@media print {
  body {
    background: #ffffff;
    color: #000000;
    padding: 0;
  }
  .app-sidebar, .app-topbar, .impersonation-bar, .no-print, .btn {
    display: none !important;
  }
  .app-main, .page-content {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
}
