/*
 * MigroStack Modern Theme System
 * Supports native dark/light modes with system preference detection
 * Professional enterprise color scheme
 */

/* ==================== ROOT VARIABLES ==================== */
:root {
  /* Brand Colors - MigroStack Blue & Purple */
  --primary-blue: #0066FF;
  --primary-blue-light: #3385FF;
  --primary-blue-dark: #0052CC;
  --primary-blue-darker: #003D99;
  --primary-purple: #7C3AED;
  --primary-purple-light: #9F67FF;
  --primary-purple-dark: #6D28D9;
  --primary-purple-darker: #5B21B6;

  /* Legacy RMON Colors (for gradual migration) */
  --rmon-orange: #D97634;
  --rmon-orange-light: #ff9933;
  --rmon-orange-dark: #c66428;
  --rmon-orange-darker: #a3501f;
  --rmon-green: #7DB343;
  --rmon-green-light: #95c95f;
  --rmon-green-dark: #6da03a;
  --rmon-green-darker: #5a8830;

  /* Light Mode Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #ffffff;

  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --text-inverse: #ffffff;

  --border-color: #dee2e6;
  --border-color-light: #e9ecef;
  --border-color-dark: #ced4da;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

  --overlay-bg: rgba(0, 0, 0, 0.5);

  /* Component Colors */
  --input-bg: #ffffff;
  --input-border: #ced4da;
  --input-focus: #0066FF;
  --input-placeholder: #adb5bd;

  --button-primary: #0066FF;
  --button-primary-hover: #0052CC;
  --button-secondary: #7C3AED;
  --button-secondary-hover: #6D28D9;

  --success: #28a745;
  --warning: #ff9800;
  --error: #dc3545;
  --info: #2196f3;

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

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;
}

/* ==================== DARK MODE ==================== */
/* Matches marketing page dark theme colors */
[data-theme="dark"] {
  --bg-primary: #0A0E27;
  --bg-secondary: #1A1F3A;
  --bg-tertiary: #252B4A;
  --bg-elevated: #1A1F3A;
  --bg-card: #1A1F3A;
  --bg-input: #1A1F3A;

  --text-primary: #FFFFFF;
  --text-secondary: #A0AEC0;
  --text-tertiary: #718096;
  --text-inverse: #0A0E27;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-color-light: rgba(255, 255, 255, 0.05);
  --border-color-dark: rgba(255, 255, 255, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.5);

  --overlay-bg: rgba(10, 14, 39, 0.8);

  --input-bg: #1A1F3A;
  --input-border: rgba(255, 255, 255, 0.1);
  --input-placeholder: #718096;
}

/* Force dark mode when explicitly set */
[data-theme="dark"] {
  color-scheme: dark;
}

/* Force light mode when explicitly set */
[data-theme="light"] {
  color-scheme: light;
}

/* ==================== GLOBAL STYLES ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* ==================== TYPOGRAPHY ==================== */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Poppins', 'Inter', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

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

a {
  color: var(--rmon-orange);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--rmon-orange-light);
  text-decoration: underline;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-family: 'Poppins', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--button-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--button-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(125, 179, 67, 0.3);
  text-decoration: none;
}

.btn-secondary {
  background: var(--button-secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--button-secondary-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(217, 118, 52, 0.3);
  text-decoration: none;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--rmon-orange);
  color: var(--rmon-orange);
}

.btn-outline:hover:not(:disabled) {
  background: var(--rmon-orange);
  color: white;
  text-decoration: none;
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-secondary);
  text-decoration: none;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* ==================== CARDS ==================== */
.card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-orange {
  border-color: var(--primary-blue);
  background: var(--bg-card);
}

[data-theme="dark"] .card-orange {
  background: rgba(0, 102, 255, 0.05);
}

[data-theme="light"] .card-orange {
  background: rgba(0, 102, 255, 0.02);
}

.card-orange:hover {
  border-color: var(--primary-blue-light);
  box-shadow: 0 8px 24px rgba(0, 102, 255, 0.3);
}

.card-green {
  border-color: var(--primary-purple);
}

[data-theme="dark"] .card-green {
  background: rgba(124, 58, 237, 0.05);
}

[data-theme="light"] .card-green {
  background: rgba(124, 58, 237, 0.02);
}

.card-green:hover {
  border-color: var(--primary-purple-light);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

.card-header {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: var(--space-lg);
}

label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.875rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text-primary);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

input::placeholder,
textarea::placeholder {
  color: var(--input-placeholder);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(125, 179, 67, 0.1);
}

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

/* ==================== ALERTS ==================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  border: 2px solid;
  margin-bottom: var(--space-lg);
  font-weight: 500;
}

.alert-success {
  background: rgba(40, 167, 69, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.alert-warning {
  background: rgba(255, 193, 7, 0.1);
  border-color: var(--warning);
  color: var(--warning);
}

.alert-error {
  background: rgba(220, 53, 69, 0.1);
  border-color: var(--error);
  color: var(--error);
}

.alert-info {
  background: rgba(23, 162, 184, 0.1);
  border-color: var(--info);
  color: var(--info);
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius-full);
}

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

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

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

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

.badge-orange {
  background: var(--rmon-orange);
  color: white;
}

.badge-green {
  background: var(--rmon-green);
  color: white;
}

/* ==================== CUSTOM SCROLLBAR ==================== */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-blue);
  border-radius: var(--radius-md);
  border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-blue-light);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-blue) var(--bg-secondary);
}

/* ==================== MODALS ==================== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--primary-blue);
  background: var(--bg-elevated);
}

.modal-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
}

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

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== THEME TOGGLE BUTTON ==================== */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 0.75rem;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-lg);
}

.theme-toggle:hover {
  transform: scale(1.1);
  border-color: var(--primary-blue);
  box-shadow: 0 8px 24px rgba(0, 102, 255, 0.3);
}

.theme-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: var(--text-primary);
  transition: all var(--transition-base);
}

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-orange { color: var(--rmon-orange); }
.text-green { color: var(--rmon-green); }

.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-orange { background: var(--rmon-orange); }
.bg-green { background: var(--rmon-green); }

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

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

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

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.animate-fade-in {
  animation: fadeIn 0.3s ease;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }

  .theme-toggle {
    top: 0.5rem;
    right: 0.5rem;
  }
}
