/* ============================================================
   Lar Digital — Brand Design System
   Premium warm palette: graphite / eucalyptus / porcelain
   ============================================================ */

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

/* --- CSS Variables --- */
:root {
  --graphite: #0E1625;
  --eucalyptus: #697F71;
  --porcelain: #F7F4EE;
  --mist: #E7ECE8;
  --sand: #D8CCB8;
  --indigo: #7279F8;
  --ink: #1B2430;
  --muted: #667085;
  --success: #1F8F5F;
  --warning: #C98A2E;
  --danger: #B5473C;
  --border: #E8E4DE;
  --white: #FFFFFF;
  --sidebar-w: 16rem;
  --header-h: 3.5rem;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(14,22,37,0.04);
  --shadow-md: 0 4px 16px rgba(14,22,37,0.06);
  --shadow-lg: 0 8px 40px rgba(14,22,37,0.08);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Base --- */
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Sidebar --- */
.ld-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 40;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--graphite);
  color: #fff;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease;
}

.ld-sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.ld-sidebar-header img {
  width: 28px;
  height: 28px;
}

.ld-sidebar-header .ld-brand-name {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ld-sidebar-header .ld-brand-tagline {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.45);
  margin-top: 1px;
}

.ld-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.625rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.ld-sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.ld-sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.ld-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

.ld-sidebar-group {
  margin-bottom: 0.25rem;
}

.ld-sidebar-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.75rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: color 0.15s;
}

.ld-sidebar-group-label:hover {
  color: rgba(255,255,255,0.55);
}

.ld-sidebar-group-label .ld-chevron {
  font-size: 0.625rem;
  transition: transform 0.2s;
}

.ld-sidebar-group.collapsed .ld-chevron {
  transform: rotate(-90deg);
}

.ld-sidebar-group.collapsed .ld-sidebar-group-items {
  display: none;
}

.ld-sidebar-group-items {
  padding: 0.125rem 0;
}

.ld-sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 450;
  color: rgba(255,255,255,0.65);
  border-radius: 8px;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
}

.ld-sidebar-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.ld-sidebar-item.active {
  background: var(--eucalyptus);
  color: #fff;
  font-weight: 500;
}

.ld-sidebar-item i {
  font-size: 1rem;
  width: 1.125rem;
  text-align: center;
  opacity: 0.75;
}

.ld-sidebar-item.active i {
  opacity: 1;
}

.ld-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  background: var(--graphite);
}

.ld-sidebar-footer .ld-user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ld-sidebar-footer .ld-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--eucalyptus);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.ld-sidebar-footer #user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fff;
  line-height: 1.2;
}

.ld-sidebar-footer #user-role {
  font-size: 0.6875rem;
  color: rgba(255,255,255,0.45);
}

.ld-sidebar-footer #logout-btn {
  width: 100%;
  padding: 0.375rem 0;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.ld-sidebar-footer #logout-btn:hover {
  background: rgba(255,255,255,0.14);
  color: #fff;
}

/* --- Cards --- */
.ld-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.ld-stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ld-stat-card .ld-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.ld-stat-card .ld-stat-label {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 450;
}

.ld-stat-card .ld-stat-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* --- Tables --- */
.ld-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}

.ld-table thead th {
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
  background: var(--porcelain);
}

.ld-table tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}

.ld-table tbody tr:hover {
  background: rgba(105,127,113,0.04);
}

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

/* --- Badges --- */
.ld-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: 9999px;
  line-height: 1.4;
}

.ld-badge-success {
  background: rgba(31,143,95,0.1);
  color: var(--success);
}

.ld-badge-warning {
  background: rgba(201,138,46,0.1);
  color: var(--warning);
}

.ld-badge-danger {
  background: rgba(181,71,60,0.1);
  color: var(--danger);
}

.ld-badge-info {
  background: rgba(114,121,248,0.1);
  color: var(--indigo);
}

.ld-badge-muted {
  background: rgba(102,112,133,0.08);
  color: var(--muted);
}

/* --- Buttons --- */
.ld-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  line-height: 1.4;
}

.ld-btn-primary {
  background: var(--graphite);
  color: #fff;
  border-color: var(--graphite);
}

.ld-btn-primary:hover {
  background: #1B2430;
}

.ld-btn-secondary {
  background: var(--white);
  color: var(--ink);
  border-color: var(--border);
}

.ld-btn-secondary:hover {
  background: var(--porcelain);
}

.ld-btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.ld-btn-success:hover {
  background: #1a7a50;
}

.ld-btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.ld-btn-danger:hover {
  background: #9e3e34;
}

.ld-btn-sm {
  padding: 0.3125rem 0.625rem;
  font-size: 0.75rem;
}

/* --- Inputs --- */
.ld-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--porcelain);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: all 0.15s;
  font-family: var(--font-sans);
}

.ld-input:focus {
  outline: none;
  border-color: var(--eucalyptus);
  box-shadow: 0 0 0 3px rgba(105,127,113,0.15);
}

.ld-input::placeholder {
  color: var(--muted);
}

/* --- Modals --- */
.ld-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,22,37,0.4);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ld-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.ld-modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.ld-modal-body {
  padding: 1.5rem;
}

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

/* --- Toast overrides for Tailwind pages --- */
.ld-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.ld-toast > div {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: ld-toast-in 0.2s ease;
}

@keyframes ld-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Header bar --- */
.ld-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.ld-header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

/* --- Mobile --- */
@media (max-width: 767px) {
  .ld-sidebar {
    transform: translateX(-100%);
  }

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

  .ld-content {
    margin-left: 0 !important;
  }
}

@media (min-width: 768px) {
  .ld-content {
    margin-left: var(--sidebar-w);
  }

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

/* iOS scroll fix */
@supports (-webkit-touch-callout: none) {
  .ld-sidebar-nav {
    max-height: -webkit-fill-available;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Utility --- */
.ld-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
}

.ld-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.ld-empty-state i {
  font-size: 2.5rem;
  opacity: 0.3;
  margin-bottom: 0.75rem;
}

/* Loading States */
@keyframes ld-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.ld-skeleton {
  background: var(--mist);
  border-radius: var(--radius-md);
  animation: ld-pulse 1.5s ease-in-out infinite;
}

.ld-skeleton-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.ld-skeleton-card .ld-skeleton-line {
  background: var(--mist);
  border-radius: 4px;
  animation: ld-pulse 1.5s ease-in-out infinite;
}

.ld-spinner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  gap: 0.75rem;
}

.ld-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--mist);
  border-top-color: var(--eucalyptus);
  border-radius: 50%;
  animation: ld-spin 0.8s linear infinite;
}

@keyframes ld-spin {
  to { transform: rotate(360deg); }
}

.ld-spinner-text {
  font-size: 0.8125rem;
  color: var(--muted);
}
