/* ==========================================================================
   GLOBAL THEME FOUNDATION & DESIGN TOKEN ENGINE (UISWAP Phase 1)
   ========================================================================== */

/* 1. Baseline / Current Theme (Default & Fallback) */
:root,
[data-theme="current"] {
  --color-primary: 37 99 235;
  --color-primary-foreground: 255 255 255;
  --color-secondary: 75 85 99;
  --color-secondary-foreground: 255 255 255;
  --color-background: 255 255 255;
  --color-foreground: 15 23 42;
  --color-muted: 241 245 249;
  --color-muted-foreground: 100 116 139;
  --color-border: 226 232 240;
  --color-destructive: 239 68 68;
  --color-destructive-foreground: 255 255 255;
  --color-success: 34 197 94;
  --color-success-foreground: 255 255 255;
  --color-warning: 245 158 11;
  --color-warning-foreground: 255 255 255;
  --color-card: 255 255 255;
  --color-card-foreground: 15 23 42;
  --color-accent: 219 234 254;
  --color-accent-foreground: 30 64 175;
  --color-ring: 37 99 235;
  --radius: .5rem;
  --radius-sm: .375rem;
  --radius-lg: .75rem;
  --shadow-surface: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-floating: 0 12px 32px rgb(15 23 42 / .16);
  --pms-theme-font: Outfit, Inter, system-ui, -apple-system, sans-serif;
  --pms-nav-bg: rgb(var(--color-card));
  --pms-nav-border: rgb(var(--color-border));
  --pms-table-header-bg: rgb(var(--color-muted) / .5);
}

.dark,
.dark[data-theme="current"],
[data-theme="current"] .dark {
  --color-primary: 59 130 246;
  --color-primary-foreground: 255 255 255;
  --color-secondary: 156 163 175;
  --color-secondary-foreground: 17 24 39;
  --color-background: 15 23 42;
  --color-foreground: 248 250 252;
  --color-muted: 30 41 59;
  --color-muted-foreground: 148 163 184;
  --color-border: 51 65 85;
  --color-destructive: 248 113 113;
  --color-destructive-foreground: 255 255 255;
  --color-success: 74 222 128;
  --color-success-foreground: 6 78 59;
  --color-warning: 251 191 36;
  --color-warning-foreground: 120 53 15;
  --color-card: 15 23 42;
  --color-card-foreground: 248 250 252;
  --color-accent: 30 58 138;
  --color-accent-foreground: 219 234 254;
  --color-ring: 96 165 250;
  --radius: .5rem;
  --pms-nav-bg: rgb(15 23 42);
  --pms-nav-border: rgb(51 65 85);
  --pms-table-header-bg: rgb(30 41 59 / .5);
}

/* 2. AppFolio-inspired Theme (Deep Navy, Emerald Accent, Crisp High Density) */
[data-theme="appfolio"] {
  --color-primary: 13 51 89; /* #0D3359 Deep Navy */
  --color-primary-foreground: 255 255 255;
  --color-secondary: 71 85 105; /* Slate 600 */
  --color-secondary-foreground: 255 255 255;
  --color-background: 244 246 248; /* #F4F6F8 Clean Light Slate */
  --color-foreground: 30 41 59; /* Slate 800 */
  --color-muted: 238 242 246; /* Cool subtle grey */
  --color-muted-foreground: 100 116 139;
  --color-border: 220 224 230; /* #DCE0E6 Crisp structured border */
  --color-destructive: 220 38 38;
  --color-destructive-foreground: 255 255 255;
  --color-success: 0 128 96; /* #008060 Signature AppFolio Emerald */
  --color-success-foreground: 255 255 255;
  --color-warning: 217 119 6;
  --color-warning-foreground: 255 255 255;
  --color-card: 255 255 255;
  --color-card-foreground: 30 41 59;
  --color-accent: 224 242 237; /* Soft emerald accent */
  --color-accent-foreground: 0 102 77;
  --color-ring: 13 51 89;
  --radius: .25rem; /* 4px crisp edges */
  --radius-sm: .125rem;
  --radius-lg: .375rem;
  --shadow-surface: 0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .08);
  --shadow-floating: 0 10px 25px -5px rgb(13 51 89 / .15);
  --pms-theme-font: Inter, system-ui, -apple-system, sans-serif;
  --pms-nav-bg: #0D3359;
  --pms-nav-border: #1A4473;
  --pms-table-header-bg: #EAEFF5;
}

[data-theme="appfolio"] body {
  font-family: var(--pms-theme-font);
}

.dark[data-theme="appfolio"],
[data-theme="appfolio"] .dark {
  --color-primary: 56 128 196;
  --color-primary-foreground: 255 255 255;
  --color-secondary: 148 163 184;
  --color-secondary-foreground: 15 23 42;
  --color-background: 10 25 47; /* Deep midnight navy */
  --color-foreground: 241 245 249;
  --color-muted: 17 34 64;
  --color-muted-foreground: 136 146 176;
  --color-border: 35 53 84;
  --color-destructive: 248 113 113;
  --color-destructive-foreground: 255 255 255;
  --color-success: 52 211 153;
  --color-success-foreground: 6 78 59;
  --color-warning: 251 191 36;
  --color-warning-foreground: 120 53 15;
  --color-card: 17 34 64;
  --color-card-foreground: 241 245 249;
  --color-accent: 20 50 80;
  --color-accent-foreground: 100 255 218;
  --color-ring: 56 128 196;
  --radius: .25rem;
  --pms-nav-bg: #0A192F;
  --pms-nav-border: #233554;
  --pms-table-header-bg: #112240;
}

/* 3. ResMan-inspired Theme (Vibrant Royal Blue, Coral/Orange Highlight, Rounded Elevations) */
[data-theme="resman"] {
  --color-primary: 0 122 204; /* #007ACC Vibrant Royal Blue */
  --color-primary-foreground: 255 255 255;
  --color-secondary: 255 107 53; /* #FF6B35 ResMan Coral Accent */
  --color-secondary-foreground: 255 255 255;
  --color-background: 248 250 252; /* #F8FAFC Ultra-clean slate */
  --color-foreground: 15 23 42;
  --color-muted: 241 245 249;
  --color-muted-foreground: 100 116 139;
  --color-border: 226 232 240;
  --color-destructive: 239 68 68;
  --color-destructive-foreground: 255 255 255;
  --color-success: 16 185 129;
  --color-success-foreground: 255 255 255;
  --color-warning: 245 158 11;
  --color-warning-foreground: 255 255 255;
  --color-card: 255 255 255;
  --color-card-foreground: 15 23 42;
  --color-accent: 238 246 255;
  --color-accent-foreground: 0 102 179;
  --color-ring: 0 122 204;
  --radius: .75rem; /* 12px modern rounded curves */
  --radius-sm: .5rem;
  --radius-lg: 1rem;
  --shadow-surface: 0 4px 6px -1px rgb(0 122 204 / .06), 0 2px 4px -2px rgb(0 122 204 / .04);
  --shadow-floating: 0 20px 25px -5px rgb(0 122 204 / .12), 0 8px 10px -6px rgb(0 122 204 / .08);
  --pms-theme-font: Outfit, Inter, system-ui, -apple-system, sans-serif;
  --pms-nav-bg: #FFFFFF;
  --pms-nav-border: #E2E8F0;
  --pms-table-header-bg: #F1F5F9;
}

[data-theme="resman"] body {
  font-family: var(--pms-theme-font);
}

.dark[data-theme="resman"],
[data-theme="resman"] .dark {
  --color-primary: 56 189 248;
  --color-primary-foreground: 15 23 42;
  --color-secondary: 251 146 60;
  --color-secondary-foreground: 15 23 42;
  --color-background: 11 15 25; /* Sleek obsidian */
  --color-foreground: 248 250 252;
  --color-muted: 23 30 46;
  --color-muted-foreground: 148 163 184;
  --color-border: 30 41 59;
  --color-destructive: 248 113 113;
  --color-destructive-foreground: 255 255 255;
  --color-success: 52 211 153;
  --color-success-foreground: 6 78 59;
  --color-warning: 251 191 36;
  --color-warning-foreground: 120 53 15;
  --color-card: 17 24 39;
  --color-card-foreground: 248 250 252;
  --color-accent: 23 37 84;
  --color-accent-foreground: 147 197 253;
  --color-ring: 56 189 248;
  --radius: .75rem;
  --pms-nav-bg: #111827;
  --pms-nav-border: #1F2937;
  --pms-table-header-bg: #1F2937;
}

/* ==========================================================================
   APPFOLIO THEME LAYOUT & COMPONENT STYLES (UISWAP Phase 3)
   ========================================================================== */

/* Layout Header & Topbar */
[data-theme="appfolio"] header,
[data-theme="appfolio"] .app-header {
  background-color: #0D3359;
  border-bottom: 1px solid #1A4473;
  color: #FFFFFF;
}

[data-theme="appfolio"] header .text-foreground,
[data-theme="appfolio"] header h1,
[data-theme="appfolio"] header h2,
[data-theme="appfolio"] header h3 {
  color: #FFFFFF !important;
}

[data-theme="appfolio"] header .text-muted-foreground {
  color: #94A3B8 !important;
}

[data-theme="appfolio"] header button:not(.bg-primary):not(.bg-emerald-600),
[data-theme="appfolio"] header a {
  color: #E2E8F0;
}

[data-theme="appfolio"] header button:hover {
  background-color: #1A4473 !important;
  color: #FFFFFF !important;
}

/* AppFolio High-Density Table Styling */
[data-theme="appfolio"] table {
  font-size: 0.8125rem;
}

[data-theme="appfolio"] table thead tr {
  background-color: #EAEFF5 !important;
  border-bottom: 2px solid #CBD5E1 !important;
}

[data-theme="appfolio"] table thead th {
  color: #334155 !important;
  font-weight: 600 !important;
  font-size: 0.75rem !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem !important;
}

[data-theme="appfolio"] table tbody td {
  padding: 0.5rem 0.75rem !important;
  border-bottom: 1px solid #E2E8F0 !important;
}

[data-theme="appfolio"] table tbody tr:hover {
  background-color: #F1F5F9 !important;
}

/* AppFolio Card & Panel Styling */
[data-theme="appfolio"] .bg-card,
[data-theme="appfolio"] .card {
  border: 1px solid #DCE0E6 !important;
  border-radius: 0.25rem !important;
  box-shadow: 0 1px 3px 0 rgba(13, 51, 89, 0.06), 0 1px 2px -1px rgba(13, 51, 89, 0.04) !important;
}

/* AppFolio Buttons */
[data-theme="appfolio"] button.bg-primary,
[data-theme="appfolio"] .btn-primary {
  background-color: #0D3359 !important;
  color: #FFFFFF !important;
  border-radius: 0.25rem !important;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

[data-theme="appfolio"] button.bg-primary:hover,
[data-theme="appfolio"] .btn-primary:hover {
  background-color: #08223D !important;
  box-shadow: 0 2px 4px 0 rgba(13, 51, 89, 0.2) !important;
}

/* AppFolio Emerald Action Accents */
[data-theme="appfolio"] .accent-emerald,
[data-theme="appfolio"] .badge-success,
[data-theme="appfolio"] .text-success {
  color: #008060 !important;
}

[data-theme="appfolio"] .bg-success,
[data-theme="appfolio"] .badge-active {
  background-color: #008060 !important;
  color: #FFFFFF !important;
}

/* AppFolio Form Controls & Inputs */
[data-theme="appfolio"] input,
[data-theme="appfolio"] select,
[data-theme="appfolio"] textarea {
  border-radius: 0.25rem !important;
  border-color: #DCE0E6 !important;
  font-size: 0.875rem;
}

[data-theme="appfolio"] input:focus,
[data-theme="appfolio"] select:focus,
[data-theme="appfolio"] textarea:focus {
  border-color: #0D3359 !important;
  ring-color: #0D3359 !important;
}

/* AppFolio Sidebar Navigation */
[data-theme="appfolio"] aside nav a.bg-primary\/10,
[data-theme="appfolio"] aside nav a.active {
  background-color: #E6EFF8 !important;
  color: #0D3359 !important;
  font-weight: 600 !important;
  border-left: 3px solid #008060 !important;
  border-radius: 0 0.25rem 0.25rem 0 !important;
}

/* Dark mode overrides for AppFolio theme */
.dark[data-theme="appfolio"] header,
[data-theme="appfolio"] .dark header {
  background-color: #0A192F !important;
  border-bottom: 1px solid #233554 !important;
}

.dark[data-theme="appfolio"] table thead tr,
[data-theme="appfolio"] .dark table thead tr {
  background-color: #112240 !important;
  border-bottom: 2px solid #233554 !important;
}

.dark[data-theme="appfolio"] table thead th,
[data-theme="appfolio"] .dark table thead th {
  color: #94A3B8 !important;
}

.dark[data-theme="appfolio"] table tbody tr:hover,
[data-theme="appfolio"] .dark table tbody tr:hover {
  background-color: #1A3052 !important;
}

.dark[data-theme="appfolio"] .bg-card,
[data-theme="appfolio"] .dark .bg-card {
  border-color: #233554 !important;
  background-color: #112240 !important;
}

/* ==========================================================================
   RESMAN THEME LAYOUT & COMPONENT STYLES (UISWAP Phase 4)
   ========================================================================== */

/* Layout Header & Topbar */
[data-theme="resman"] header,
[data-theme="resman"] .app-header {
  background-color: #FFFFFF;
  border-bottom: 2px solid #EBF5FB;
  box-shadow: 0 4px 12px -2px rgba(0, 122, 204, 0.06);
}

/* ResMan Modern Curved Elevation Cards */
[data-theme="resman"] .bg-card,
[data-theme="resman"] .card {
  border: 1px solid #E2E8F0 !important;
  border-radius: 0.75rem !important;
  box-shadow: 0 4px 14px -2px rgba(0, 122, 204, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.03) !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

[data-theme="resman"] .bg-card:hover,
[data-theme="resman"] .card:hover {
  box-shadow: 0 8px 20px -4px rgba(0, 122, 204, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.04) !important;
}

/* ResMan Modern Spacious Tables */
[data-theme="resman"] table {
  font-size: 0.875rem;
  border-collapse: separate;
  border-spacing: 0;
}

[data-theme="resman"] table thead tr {
  background-color: #F8FAFC !important;
  border-bottom: 2px solid #E2E8F0 !important;
}

[data-theme="resman"] table thead th {
  color: #1E293B !important;
  font-weight: 700 !important;
  font-size: 0.8125rem !important;
  letter-spacing: 0.02em;
  padding: 0.75rem 1rem !important;
}

[data-theme="resman"] table tbody td {
  padding: 0.75rem 1rem !important;
  border-bottom: 1px solid #F1F5F9 !important;
}

[data-theme="resman"] table tbody tr:hover {
  background-color: #F0F7FD !important;
}

/* ResMan Royal Blue Primary Buttons */
[data-theme="resman"] button.bg-primary,
[data-theme="resman"] .btn-primary {
  background: linear-gradient(135deg, #007ACC 0%, #0066AA 100%) !important;
  color: #FFFFFF !important;
  border-radius: 0.5rem !important;
  font-weight: 600;
  box-shadow: 0 2px 8px -1px rgba(0, 122, 204, 0.35) !important;
  transition: all 0.2s ease-in-out;
}

[data-theme="resman"] button.bg-primary:hover,
[data-theme="resman"] .btn-primary:hover {
  background: linear-gradient(135deg, #0088E0 0%, #007ACC 100%) !important;
  box-shadow: 0 4px 14px 0 rgba(0, 122, 204, 0.45) !important;
  transform: translateY(-1px);
}

/* ResMan Coral Accent Badges & Highlights */
[data-theme="resman"] .badge-coral,
[data-theme="resman"] .accent-coral {
  background-color: #FF6B35 !important;
  color: #FFFFFF !important;
  border-radius: 9999px !important;
}

[data-theme="resman"] .badge-warning {
  background-color: #FFF4EE !important;
  color: #D94814 !important;
  border: 1px solid #FFD8C7 !important;
}

/* ResMan Smooth Curved Form Controls */
[data-theme="resman"] input,
[data-theme="resman"] select,
[data-theme="resman"] textarea {
  border-radius: 0.5rem !important;
  border-color: #CBD5E1 !important;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[data-theme="resman"] input:focus,
[data-theme="resman"] select:focus,
[data-theme="resman"] textarea:focus {
  border-color: #007ACC !important;
  box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.15) !important;
}

/* ResMan Sidebar Navigation */
[data-theme="resman"] aside nav a.bg-primary\/10,
[data-theme="resman"] aside nav a.active {
  background-color: #EBF5FB !important;
  color: #007ACC !important;
  font-weight: 700 !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 1px 3px rgba(0, 122, 204, 0.12) !important;
}

/* Dark mode overrides for ResMan theme */
.dark[data-theme="resman"] header,
[data-theme="resman"] .dark header {
  background-color: #111827 !important;
  border-bottom: 2px solid #1F2937 !important;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.4) !important;
}

.dark[data-theme="resman"] table thead tr,
[data-theme="resman"] .dark table thead tr {
  background-color: #1F2937 !important;
  border-bottom: 2px solid #374151 !important;
}

.dark[data-theme="resman"] table thead th,
[data-theme="resman"] .dark table thead th {
  color: #F3F4F6 !important;
}

.dark[data-theme="resman"] table tbody tr:hover,
[data-theme="resman"] .dark table tbody tr:hover {
  background-color: #1A263D !important;
}

.dark[data-theme="resman"] .bg-card,
[data-theme="resman"] .dark .bg-card {
  border-color: #374151 !important;
  background-color: #1F2937 !important;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.3) !important;
}
