/* ========================================
   MAIN STYLESHEET
   ======================================= */

/* CSS Custom Properties (Variables) */
:root {
  /* Light Mode Colors */
  --theme-bg-primary: #ffffff;
  --theme-bg-secondary: #f8fafc;
  --theme-bg-tertiary: #f1f5f9;
  --theme-bg-quaternary: #e2e8f0;
  
  --theme-text-primary: #1a202c;
  --theme-text-secondary: #64748b;
  --theme-text-tertiary: #94a3b8;
  --theme-text-inverse: #ffffff;
  
  --theme-border-primary: #e2e8f0;
  --theme-border-secondary: #cbd5e1;
  
  --theme-accent-blue: #3b82f6;
  --theme-accent-blue-hover: #2563eb;
  --theme-accent-green: #10b981;
  --theme-accent-green-hover: #059669;
  --theme-accent-red: #ef4444;
  --theme-accent-orange: #f59e0b;
  --theme-accent-yellow: #eab308;
  
  /* Gradients */
  --theme-sidebar-gradient: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  --theme-header-gradient: linear-gradient(90deg, var(--theme-bg-secondary) 0%, var(--theme-bg-primary) 100%);
  
  /* Shadows */
  --theme-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --theme-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --theme-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.2);
  
  /* Transitions */
  --theme-transition-fast: 0.15s ease;
  --theme-transition-normal: 0.2s ease;
  --theme-transition-slow: 0.3s ease;
  
  /* Border Radius */
  --theme-radius-sm: 0.25rem;
  --theme-radius-md: 0.375rem;
  --theme-radius-lg: 0.5rem;
  --theme-radius-xl: 0.75rem;
  --theme-radius-full: 9999px;
  
  /* Spacing */
  --theme-spacing-xs: 0.25rem;
  --theme-spacing-sm: 0.5rem;
  --theme-spacing-md: 0.75rem;
  --theme-spacing-lg: 1rem;
  --theme-spacing-xl: 1.5rem;
  --theme-spacing-2xl: 2rem;
  
  /* Typography */
  --theme-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --theme-font-size-xs: 0.75rem;
  --theme-font-size-sm: 0.813rem;
  --theme-font-size-md: 0.875rem;
  --theme-font-size-lg: 1rem;
  --theme-font-size-xl: 1.125rem;
  --theme-font-size-2xl: 1.25rem;
  --theme-font-size-3xl: 1.5rem;
  --theme-font-weight-normal: 400;
  --theme-font-weight-medium: 500;
  --theme-font-weight-semibold: 600;
  --theme-font-weight-bold: 700;
  
  /* Layout */
  --theme-sidebar-width: 250px;
  --theme-header-height: 70px;
  --theme-z-index-dropdown: 1000;
  --theme-z-index-modal: 1050;
  --theme-z-index-toast: 1100;
}

/* Dark Mode Overrides */
body.dark-mode {
  --theme-bg-primary: #020617;
  --theme-bg-secondary: #111827;
  --theme-bg-tertiary: #374151;
  --theme-bg-quaternary: #4b5563;
  
  --theme-text-primary: #ffffff;
  --theme-text-secondary: #9ca3af;
  --theme-text-tertiary: #6b7280;
  
  --theme-border-primary: #374151;
  --theme-border-secondary: #4b5563;
  
  --theme-sidebar-gradient: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
  --theme-header-gradient: linear-gradient(90deg, var(--theme-bg-tertiary) 0%, var(--theme-bg-secondary) 100%);
  
  --theme-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --theme-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4); 
  --theme-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.6);
}

/* Theme State Utilities */
.theme-transition {
  transition: all var(--theme-transition-normal);
}

.theme-transition-fast {
  transition: all var(--theme-transition-fast);
}

.theme-transition-slow {
  transition: all var(--theme-transition-slow);
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0; 
  box-sizing: border-box;
}

html, body {
  font-family: var(--theme-font-family);
  height: 100vh;
  overflow: hidden;
}

body {
  background-color: var(--theme-bg-primary);
  color: var(--theme-text-primary);
  transition: background-color var(--theme-transition-normal), color var(--theme-transition-normal);
}

/* Additional Global Utilities */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-1 { flex: 1; }

.gap-sm { gap: var(--theme-spacing-sm); }
.gap-md { gap: var(--theme-spacing-md); }
.gap-lg { gap: var(--theme-spacing-lg); }
.gap-xl { gap: var(--theme-spacing-xl); }

.p-sm { padding: var(--theme-spacing-sm); }
.p-md { padding: var(--theme-spacing-md); }
.p-lg { padding: var(--theme-spacing-lg); }
.p-xl { padding: var(--theme-spacing-xl); }

.m-sm { margin: var(--theme-spacing-sm); }
.m-md { margin: var(--theme-spacing-md); }
.m-lg { margin: var(--theme-spacing-lg); }
.m-xl { margin: var(--theme-spacing-xl); }

.rounded-sm { border-radius: var(--theme-radius-sm); }
.rounded-md { border-radius: var(--theme-radius-md); }
.rounded-lg { border-radius: var(--theme-radius-lg); }
.rounded-full { border-radius: var(--theme-radius-full); }

.shadow-sm { box-shadow: var(--theme-shadow-sm); }
.shadow-md { box-shadow: var(--theme-shadow-md); }
.shadow-lg { box-shadow: var(--theme-shadow-lg); }

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--theme-spacing-sm);
  padding: var(--theme-spacing-sm) var(--theme-spacing-lg);
  border-radius: var(--theme-radius-md);
  font-size: var(--theme-font-size-md);
  font-weight: var(--theme-font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--theme-transition-normal);
  border: none;
  white-space: nowrap;
}

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

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

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

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

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

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

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

.btn-danger {
  background-color: var(--theme-accent-red);
  color: var(--theme-text-inverse);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(0.94);
}

.btn-sm {
  padding: var(--theme-spacing-xs) var(--theme-spacing-md);
  font-size: var(--theme-font-size-sm);
}

.btn-lg {
  padding: var(--theme-spacing-md) var(--theme-spacing-xl);
  font-size: var(--theme-font-size-lg);
}

/* Form Elements */
.form-control {
  width: 100%;
  padding: var(--theme-spacing-sm) var(--theme-spacing-md);
  border: 1px solid var(--theme-border-primary);
  border-radius: var(--theme-radius-md);
  background-color: var(--theme-bg-primary);
  color: var(--theme-text-primary);
  font-size: var(--theme-font-size-md);
  transition: all var(--theme-transition-normal);
}

.form-control:focus {
  outline: none;
  border-color: var(--theme-accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Shared Page Patterns */
.cc-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--theme-spacing-md);
  margin-bottom: var(--theme-spacing-lg);
}

.cc-page-header h1 {
  margin: 0;
}

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

.cc-data-table th,
.cc-data-table td {
  padding: var(--theme-spacing-sm) var(--theme-spacing-md);
  border-bottom: 1px solid var(--theme-border-primary);
  vertical-align: middle;
}

.cc-data-table th {
  color: var(--theme-text-secondary);
  font-size: var(--theme-font-size-xs);
  font-weight: var(--theme-font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-row-inactive {
  opacity: 0.7;
}

.cc-action-cell {
  min-width: 220px;
}

.cc-action-buttons {
  display: flex;
  gap: var(--theme-spacing-sm);
  flex-wrap: wrap;
}

.cc-btn-action {
  background-color: var(--theme-accent-blue);
  color: var(--theme-text-inverse);
}

.cc-btn-action:hover {
  background-color: var(--theme-accent-blue-hover);
}

.cc-btn-warning {
  background-color: var(--theme-accent-orange);
  color: var(--theme-text-inverse);
}

.cc-btn-warning:hover {
  filter: brightness(0.94);
}

.cc-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--theme-spacing-xs) var(--theme-spacing-sm);
  border-radius: var(--theme-radius-full);
  font-size: var(--theme-font-size-xs);
  font-weight: var(--theme-font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cc-badge-admin {
  background-color: var(--theme-accent-red);
  color: var(--theme-text-inverse);
}

.cc-badge-customer {
  background-color: var(--theme-accent-blue);
  color: var(--theme-text-inverse);
}

.cc-badge-low {
  background-color: var(--theme-bg-tertiary);
  color: var(--theme-text-primary);
  border: 1px solid var(--theme-border-primary);
}

.cc-badge-normal {
  background-color: var(--theme-accent-blue);
  color: var(--theme-text-inverse);
}

.cc-badge-high {
  background-color: var(--theme-accent-orange);
  color: var(--theme-text-inverse);
}

.cc-badge-critical {
  background-color: var(--theme-accent-red);
  color: var(--theme-text-inverse);
}

.cc-status-active {
  color: var(--theme-accent-green);
  font-weight: var(--theme-font-weight-semibold);
}

.cc-status-inactive {
  color: var(--theme-text-secondary);
  font-weight: var(--theme-font-weight-semibold);
}

.cc-toast {
  position: fixed;
  right: var(--theme-spacing-xl);
  bottom: var(--theme-spacing-xl);
  background-color: var(--theme-accent-green);
  color: var(--theme-text-inverse);
  border-radius: var(--theme-radius-md);
  padding: var(--theme-spacing-sm) var(--theme-spacing-lg);
  box-shadow: var(--theme-shadow-lg);
  z-index: 1100;
}

.cc-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--theme-spacing-lg);
}

.cc-modal-content {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-primary);
  border-radius: var(--theme-radius-lg);
  box-shadow: var(--theme-shadow-lg);
  padding: var(--theme-spacing-xl);
}

.cc-confirm-dialog {
  width: min(500px, 100%);
}

.cc-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--theme-spacing-xs);
  margin-bottom: var(--theme-spacing-md);
}

.cc-form-group label {
  color: var(--theme-text-primary);
  font-size: var(--theme-font-size-sm);
  font-weight: var(--theme-font-weight-medium);
}

.cc-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-spacing-sm);
  color: var(--theme-text-secondary);
  font-size: var(--theme-font-size-sm);
  cursor: pointer;
  transition: color var(--theme-transition-normal);
}

.cc-checkbox-label:hover {
  color: var(--theme-text-primary);
}

.cc-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--theme-accent-blue);
}

.cc-form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--theme-spacing-md);
}

.cc-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--theme-spacing-sm);
  margin-top: var(--theme-spacing-lg);
}

.cc-error-message {
  margin-bottom: var(--theme-spacing-md);
  color: var(--theme-accent-red);
  font-weight: var(--theme-font-weight-medium);
}

.cc-tabs {
  display: flex;
  gap: var(--theme-spacing-sm);
  margin-bottom: var(--theme-spacing-lg);
  border-bottom: 1px solid var(--theme-border-primary);
}

.cc-tab-button {
  background: none;
  border: none;
  padding: var(--theme-spacing-sm) var(--theme-spacing-md);
  cursor: pointer;
  color: var(--theme-text-secondary);
  font-weight: var(--theme-font-weight-medium);
  border-bottom: 2px solid transparent;
  transition: all var(--theme-transition-normal);
  margin-bottom: -1px;
}

.cc-tab-button:hover {
  color: var(--theme-accent-blue);
  background-color: var(--theme-bg-secondary);
}

.cc-tab-button.active {
  color: var(--theme-accent-blue);
  border-bottom-color: var(--theme-accent-blue);
}

.checkbox {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--theme-accent-blue);
  cursor: pointer;
}

/* Icons */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-sm {
  width: 1.25rem;
  height: 1.25rem;
  font-size: var(--theme-font-size-lg);
}

.icon-md {
  width: 2rem;
  height: 2rem;
  font-size: var(--theme-font-size-2xl);
}

.icon-lg {
  width: 3rem;
  height: 3rem;
  font-size: var(--theme-font-size-3xl);
}

.icon-bg {
  background-color: var(--theme-bg-secondary);
  border-radius: var(--theme-radius-md);
}

/* Status Indicators */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--theme-spacing-xs);
  padding: var(--theme-spacing-xs) var(--theme-spacing-sm);
  border-radius: var(--theme-radius-full);
  font-size: var(--theme-font-size-xs);
  font-weight: var(--theme-font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-success {
  background-color: var(--theme-accent-green);
  color: var(--theme-text-inverse);
}

.status-info {
  background-color: var(--theme-accent-blue);
  color: var(--theme-text-inverse);
}

.status-warning {
  background-color: var(--theme-accent-orange);
  color: var(--theme-text-inverse);
}

.status-error {
  background-color: var(--theme-accent-red);
  color: var(--theme-text-inverse);
}

/* Loading States */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--theme-border-primary);
  border-top: 3px solid var(--theme-accent-blue);
  border-radius: var(--theme-radius-full);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Utilities */
@media (max-width: 640px) {
  .mobile-hidden { display: none; }
  .mobile-only { display: block; }

  .cc-page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cc-form-row {
    grid-template-columns: 1fr;
  }

  .cc-modal-content {
    padding: var(--theme-spacing-lg);
  }
}

@media (min-width: 641px) {
  .mobile-only { display: none; }
  .desktop-hidden { display: none; }
  .desktop-only { display: block; }
}

@media (max-width: 900px) {
  .cc-data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .cc-action-cell {
    min-width: 160px;
  }
}
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }
    #blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }
