/* ===== CSS Variables ===== */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f9fc;
  --bg-tertiary: #e8eef5;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --text-tertiary: #8a8a8a;
  
  /* Brand Colors */
  --color-primary: #1963e3;
  --color-primary-dark: #1450c4;
  --color-primary-light: #4a8cef;
  --color-secondary: #1963e3;
  --color-accent: #1963e3;
  
  /* Status Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  --color-info: #3b82f6;
  
  /* UI Elements */
  --border-color: #dee2e6;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
}

/* Font Awesome - Prevent FOIT/FOUT */
@font-face {
  font-family: 'Font Awesome 6 Free';
  font-display: swap;
}

@font-face {
  font-family: 'Font Awesome 6 Brands';
  font-display: swap;
}

/* ===== Dark Theme ===== */
[data-theme="dark"] {
  --bg-primary: #0a0a0a;
  --bg-secondary: #121212;
  --bg-tertiary: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #2a2a2a;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 15px -3px rgba(25, 99, 227, 0.2);
  --shadow-xl: 0 20px 25px -5px rgba(25, 99, 227, 0.3);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  /* Prevent layout shift from scrollbar */
  overflow-y: scroll;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color var(--transition-base), color var(--transition-base);
  /* Prevent content shift */
  min-height: 100vh;
  /* Optimize rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-md);
}

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(--spacing-md);
}

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

a:hover {
  color: var(--color-primary-dark);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  gap: 0.5rem;
}

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

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

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

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

.btn-success:hover:not(:disabled) {
  opacity: 0.9;
}

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

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

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

label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--text-primary);
}

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

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

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

/* ===== Cards ===== */
.card {
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-xl);
  transition: all var(--transition-base);
}

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

.card-header {
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0;
}

.card-body {
  padding: var(--spacing-md) 0;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
}

.badge-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.badge-info {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--color-info);
}

.badge-primary {
  background-color: rgba(79, 70, 229, 0.1);
  color: var(--color-primary);
}

/* ===== Tables ===== */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-primary);
}

th {
  background-color: var(--bg-secondary);
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
}

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

tr:hover {
  background-color: var(--bg-secondary);
}

/* ===== Alerts ===== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--color-success);
  color: var(--color-success);
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--color-error);
  color: var(--color-error);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-left: 4px solid var(--color-warning);
  color: var(--color-warning);
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--color-info);
  color: var(--color-info);
}

/* ===== Grid System ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--spacing-lg);
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 calc(-1 * var(--spacing-md));
}

.col {
  flex: 1;
  padding: 0 var(--spacing-md);
}

.col-2 { flex: 0 0 16.666%; max-width: 16.666%; padding: 0 var(--spacing-md); }
.col-3 { flex: 0 0 25%; max-width: 25%; padding: 0 var(--spacing-md); }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; padding: 0 var(--spacing-md); }
.col-6 { flex: 0 0 50%; max-width: 50%; padding: 0 var(--spacing-md); }
.col-8 { flex: 0 0 66.666%; max-width: 66.666%; padding: 0 var(--spacing-md); }
.col-12 { flex: 0 0 100%; max-width: 100%; padding: 0 var(--spacing-md); }

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

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

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

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

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .col-2, .col-3, .col-4, .col-6, .col-8 {
    flex: 0 0 100%;
    max-width: 100%;
  }
  
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }
  
  .container {
    padding: 0 var(--spacing-md);
  }
}

/* ===== Loading Spinner ===== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

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

/* ===== Responsive Display Utilities ===== */
.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

/* ===== Mobile Orders Card View ===== */
.orders-mobile-grid {
  display: none;
  gap: 1rem;
}

.order-mobile-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s;
}

.order-mobile-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.order-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.order-mobile-id {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.order-mobile-vm-name {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.order-mobile-details {
  padding: 1rem;
}

.order-mobile-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.order-mobile-detail-row:last-child {
  border-bottom: none;
}

.order-mobile-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-mobile-label i {
  color: var(--primary);
  width: 1rem;
  text-align: center;
}

.order-mobile-value {
  font-size: 0.8125rem;
  color: var(--text-primary);
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.order-mobile-vm-info {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.order-mobile-footer {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

/* ===== Order Summary Styles ===== */
.summary-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

.summary-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.summary-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.summary-section-icon {
  font-size: 1.5rem;
  color: var(--primary);
}

.summary-section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.summary-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.summary-icon {
  font-size: 1rem;
  color: var(--text-secondary);
  width: 1.25rem;
  text-align: center;
}

.summary-value {
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: right;
  max-width: 50%;
  word-break: break-word;
}

/* Resources Group */
.summary-resources {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border-color);
}

.summary-resource-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  text-align: center;
}

.summary-resource-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.summary-resource-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.summary-resource-value {
  font-size: 0.9375rem;
  color: var(--text-primary);
  font-weight: 700;
}

/* Total Box */
.summary-total-box {
  background: linear-gradient(135deg, var(--primary), var(--color-secondary));
  padding: 1.25rem;
  border-radius: 10px;
  margin: 1rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.summary-total-label {
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-total-value {
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
}

/* Balance Section */
.summary-balance-section {
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 2px solid var(--border-color);
}

/* Captcha */
.summary-captcha {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
}

/* Actions */
.summary-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.summary-actions .btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  .desktop-only {
    display: none !important;
  }
  
  .mobile-only {
    display: block;
  }
  
  .orders-mobile-grid {
    display: flex;
    flex-direction: column;
  }
  
  .data-table-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch !important;
  }
  
  .table-actions {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }
  
  .table-search {
    width: 100%;
  }
  
  .table-actions .btn {
    width: 100%;
    justify-content: center;
  }
  
  .card-title {
    font-size: 1.25rem;
  }
  
  /* Summary Mobile Styles */
  .summary-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .summary-card {
    padding: 1rem;
  }
  
  .summary-section-title {
    font-size: 1rem;
  }
  
  .summary-resources {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .summary-resource-item {
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    padding: 0.75rem;
  }
  
  .summary-resource-icon {
    font-size: 1.5rem;
    margin-bottom: 0;
    margin-right: 0.75rem;
  }
  
  .summary-resource-info {
    display: flex;
    flex-direction: column;
  }
  
  .summary-total-box {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .summary-total-value {
    font-size: 1.25rem;
  }
  
  .summary-actions {
    flex-direction: column;
  }
  
  .summary-actions .btn {
    width: 100%;
  }
}