/**
 * Visant Design System - Claude-inspired Theme
 *
 * A warm, minimal design with cream backgrounds and orange accents.
 * Import this file in all HTML templates for consistent styling.
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
  /* Backgrounds */
  --bg-primary: #FAF9F7;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F5F4F2;
  --bg-hover: #EFEDEA;

  /* Text */
  --text-primary: #1A1A1A;
  --text-secondary: #6B6B6B;
  --text-muted: #9B9B9B;
  --text-inverse: #FFFFFF;

  /* Accent */
  --accent-primary: #D97706;
  --accent-hover: #B45309;
  --accent-light: #FEF3C7;
  --accent-text: #92400E;

  /* Borders */
  --border-light: #E5E5E5;
  --border-medium: #D4D4D4;
  --border-focus: #D97706;

  /* Semantic Colors */
  --success: #059669;
  --success-bg: #D1FAE5;
  --success-text: #065F46;

  --error: #DC2626;
  --error-bg: #FEE2E2;
  --error-text: #991B1B;

  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --warning-text: #92400E;

  --info: #2563EB;
  --info-bg: #DBEAFE;
  --info-text: #1E40AF;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

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

  /* Typography */
  --font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
}

/* ============================================
   Base Styles
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--space-md) 0;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

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

p {
  margin: 0 0 var(--space-md) 0;
  color: var(--text-secondary);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.625rem 1.25rem;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--border-medium);
}

.btn-danger {
  background-color: var(--error);
  color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
  background-color: #B91C1C;
}

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

.btn-success:hover:not(:disabled) {
  background-color: #047857;
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

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

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: var(--font-size-base);
}

/* ============================================
   Cards
   ============================================ */
.card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-lg);
}

.card-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.form-input:disabled,
.form-select:disabled {
  background-color: var(--bg-tertiary);
  cursor: not-allowed;
}

.form-input[readonly] {
  background-color: var(--bg-tertiary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--error);
}

/* Checkbox and Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.form-check-input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent-primary);
}

/* ============================================
   Tables
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
}

.table tbody tr:hover {
  background-color: var(--bg-tertiary);
}

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

/* ============================================
   Badges & Status
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: 9999px;
}

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

.badge-error {
  background-color: var(--error-bg);
  color: var(--error-text);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
}

.badge-info {
  background-color: var(--info-bg);
  color: var(--info-text);
}

.badge-neutral {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid;
}

.alert-success {
  background-color: var(--success-bg);
  border-color: var(--success);
  color: var(--success-text);
}

.alert-error {
  background-color: var(--error-bg);
  border-color: var(--error);
  color: var(--error-text);
}

.alert-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning-text);
}

.alert-info {
  background-color: var(--info-bg);
  border-color: var(--info);
  color: var(--info-text);
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ============================================
   Navigation
   ============================================ */
.nav-link {
  color: var(--accent-primary);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================
   Layout Utilities
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.justify-end {
  justify-content: flex-end;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

.grid {
  display: grid;
}

/* ============================================
   Header
   ============================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) 0;
}

.page-title {
  margin: 0;
  font-size: var(--font-size-2xl);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ============================================
   Info Rows (Key-Value pairs)
   ============================================ */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-light);
}

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

.info-label {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 140px;
  flex-shrink: 0;
}

.info-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* ============================================
   Toast / Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: 450px;
  pointer-events: all;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}

.toast.hide {
  transform: translateX(400px);
  opacity: 0;
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--text-inverse);
}

.toast.success .toast-icon { background: var(--success); }
.toast.error .toast-icon { background: var(--error); }
.toast.info .toast-icon { background: var(--info); }

.toast-content { flex: 1; }

.toast-message {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text-primary);
}

/* ============================================
   Loading States
   ============================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-light);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* ============================================
   Auth Page Specific
   ============================================ */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl);
}

.auth-logo {
  display: block;
  max-width: 120px;
  margin: 0 auto var(--space-lg);
}

.auth-title {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* ============================================
   Dashboard Specific
   ============================================ */
.dashboard-layout {
  padding: var(--space-lg);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

/* ============================================
   Device/Camera Cards
   ============================================ */
.device-card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.device-card:hover {
  box-shadow: var(--shadow-lg);
}

.device-card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background-color: var(--bg-tertiary);
}

.device-card-body {
  padding: var(--space-md);
}

.device-card-title {
  margin: 0 0 var(--space-xs) 0;
  font-size: var(--font-size-base);
  font-weight: 600;
}

.device-card-id {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.mt-0 { margin-top: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.hidden { display: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
