/* ============================================================
   UniqClean Portal — Global Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Colors */
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-light: #eef2ff;
  --c-secondary: #6366f1;

  --c-bg: #f8f9fc;
  --c-bg-card: #ffffff;
  --c-bg-sidebar: #0f172a;
  --c-bg-sidebar-hover: #1e293b;
  --c-bg-sidebar-active: #312e81;

  --c-text: #1e293b;
  --c-text-muted: #64748b;
  --c-text-light: #94a3b8;
  --c-text-sidebar: #cbd5e1;
  --c-text-sidebar-active: #ffffff;

  --c-border: #e2e8f0;
  --c-border-light: #f1f5f9;

  --c-success: #10b981;
  --c-success-bg: #ecfdf5;
  --c-warning: #f59e0b;
  --c-warning-bg: #fffbeb;
  --c-danger: #dc2626;
  --c-danger-bg: #fef2f2;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 0.72rem;
  --fs-sm: 0.825rem;
  --fs-base: 0.9rem;
  --fs-md: 1rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.4rem;
  --fs-2xl: 1.75rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;

  /* Border radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.15);

  /* Transitions */
  --transition: all 0.15s ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--c-text);
  background-color: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--c-text);
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

a {
  color: var(--c-primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover { color: var(--c-primary-hover); }

/* ============================================================
   App Layout
   ============================================================ */

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

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--c-bg-sidebar);
  color: var(--c-text-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #1e293b;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.sidebar-logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
  letter-spacing: -0.5px;
}

.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo-sub {
  font-size: 0.7rem;
  color: var(--c-text-light);
  margin-top: 1px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  background: rgba(255,255,255,0.04);
  border-radius: var(--r-md);
}

.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #6366f1, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { min-width: 0; flex: 1; }
.sidebar-user-email {
  font-size: 0.78rem;
  color: var(--c-text-sidebar-active);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.68rem;
  color: var(--c-text-light);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-text-light);
  padding: 0.75rem 0.75rem 0.5rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text-sidebar);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.sidebar-link:hover {
  background: var(--c-bg-sidebar-hover);
  color: var(--c-text-sidebar-active);
}

.sidebar-link.active {
  background: var(--c-bg-sidebar-active);
  color: var(--c-text-sidebar-active);
  font-weight: 600;
}

.sidebar-link-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid #1e293b;
}

.sidebar-signout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: transparent;
  color: var(--c-text-sidebar);
  border: 1px solid #334155;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-signout:hover {
  background: #1e293b;
  color: #fff;
  border-color: #475569;
}

/* Main content area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--c-bg);
}

.main-header {
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  padding: 1.25rem 2rem;
}

.main-header h1 {
  font-size: var(--fs-xl);
  margin: 0;
}

.main-header-sub {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  margin-top: 0.25rem;
}

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

/* ============================================================
   Components
   ============================================================ */

/* Card */
.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--c-border-light);
}

.card-header h2,
.card-header h3 {
  font-size: var(--fs-lg);
  margin: 0;
}

.card-header p {
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
  margin-top: 0.2rem;
}

.card-body {
  padding: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--c-primary-hover);
  box-shadow: 0 2px 8px rgba(79,70,229,0.25);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn-secondary:hover {
  background: var(--c-bg);
  border-color: #cbd5e1;
}

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

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: var(--fs-xs);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Form fields */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input,
.form-select,
.form-textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-base);
  background: #fff;
  color: var(--c-text);
  transition: var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

.form-input::placeholder {
  color: var(--c-text-light);
}

/* Table */
.table-container {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--c-border-light);
  gap: 1rem;
}

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

.table th {
  text-align: left;
  padding: 0.7rem 1.25rem;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--c-text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
}

.table td {
  padding: 0.75rem 1.25rem;
  font-size: var(--fs-base);
  border-bottom: 1px solid var(--c-border-light);
  color: var(--c-text);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-success { background: var(--c-success-bg); color: #065f46; }
.badge-warning { background: var(--c-warning-bg); color: #92400e; }
.badge-danger { background: var(--c-danger-bg); color: #991b1b; }
.badge-info { background: var(--c-primary-light); color: #4338ca; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--c-text-muted);
  font-size: var(--fs-sm);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Notification */
.notification {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 400px;
}

.notification-success { background: var(--c-success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.notification-error { background: var(--c-danger-bg); color: #991b1b; border: 1px solid #fecaca; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}

.modal {
  background: #fff;
  border-radius: var(--r-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--c-border-light);
}

.modal-header h2 { font-size: var(--fs-lg); }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--c-text-light);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.modal-close:hover { color: var(--c-text); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--c-border-light);
}

/* Responsive */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; padding: 0.5rem; }
  .sidebar-link { white-space: nowrap; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 1rem; }
  .main-header { padding: 1rem; }
}
