/* PowerTV License Server - Professional Dark Theme */
/* Modern dark design with enhanced visual hierarchy */

:root {
  /* Dark Theme Primary Colors */
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --primary-color: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  
  /* Accent Colors */
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  --secondary-color: #10b981;
  --secondary-dark: #059669;
  --secondary-light: #34d399;
  
  /* Dark Mode Colors */
  --bg-primary: #0f172a;      /* Main background */
  --bg-secondary: #1e293b;    /* Card backgrounds */
  --bg-tertiary: #334155;     /* Elevated elements */
  --bg-hover: #475569;        /* Hover states */
  
  /* Text Colors - Enhanced for better contrast */
  --text-primary: #ffffff;    /* Main text - Pure white for maximum contrast */
  --text-secondary: #e2e8f0;  /* Secondary text - Light gray */
  --text-muted: #cbd5e1;      /* Muted text - Medium gray */
  --text-disabled: #94a3b8;   /* Disabled text - Darker but still readable */
  
  /* Border Colors */
  --border-primary: #334155;
  --border-secondary: #475569;
  --border-focus: #6366f1;
  
  /* Status Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Shadows */
  --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 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);
}

/* Global Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base Styles */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(at 20% 80%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 80% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 40% 40%, rgba(6, 182, 212, 0.08) 0px, transparent 50%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Login Container */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-secondary);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 48px;
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  text-align: center;
  border: 1px solid var(--border-primary);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-gradient);
}

.login-card h1 {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.login-card p {
  color: var(--text-secondary);
  margin-bottom: 36px;
  font-size: 0.95rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 24px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.025em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-primary);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.2s ease;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 400;
}

/* Special styling for select dropdowns */
.form-group select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23f1f5f9' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 16px center;
  background-repeat: no-repeat;
  background-size: 12px;
  padding-right: 40px;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
}

/* Select option styling */
.form-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 8px 12px;
  border: none;
}

/* Specific styling for tier select */
#createTierId {
  background: var(--bg-primary) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23f1f5f9' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
  background-position: right 16px center !important;
  background-repeat: no-repeat !important;
  background-size: 12px !important;
  color: var(--text-primary) !important;
  border: 2px solid var(--border-primary) !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  padding-right: 40px !important;
}

#createTierId:focus {
  border-color: var(--primary-color) !important;
  background: var(--bg-tertiary) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
  background-position: right 16px center !important;
  background-repeat: no-repeat !important;
  background-size: 12px !important;
}

#createTierId option {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-disabled);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
  background: var(--bg-tertiary);
}

.form-group select:hover {
  border-color: var(--border-secondary);
  background: var(--bg-tertiary);
}

.form-group select:focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
  background-position: right 16px center !important;
  background-repeat: no-repeat !important;
  background-size: 12px !important;
}

/* Button Styles */
.btn {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-tertiary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

/* Dashboard */
.dashboard {
  display: none;
  min-height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
  background-image: 
    radial-gradient(at 20% 80%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
    radial-gradient(at 80% 20%, rgba(139, 92, 246, 0.08) 0px, transparent 50%);
  overflow-x: hidden;
}

.dashboard.show {
  display: block;
}

/* Header */
.header {
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  padding: 20px 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border-primary);
}

.header-content {
  width: 100%;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header h1 {
  color: var(--text-primary);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Container */
.container {
  width: 100%;
  margin: 0 auto;
  padding: 32px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 20px;
  border: 1px solid var(--border-primary);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-gradient);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-icon.licenses { 
  background: var(--primary-gradient); 
}
.stat-icon.active { 
  background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
}
.stat-icon.expired { 
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); 
}
.stat-icon.validations { 
  background: var(--accent-gradient); 
}

.stat-info h3 {
  font-size: 2.25rem;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.stat-info p {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

/* Card */
.card {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  border: 1px solid var(--border-primary);
  width: 100%;
}

.card h2 {
  color: var(--text-primary);
  margin-bottom: 24px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-primary);
  margin-bottom: 32px;
  gap: 8px;
}

.tab {
  padding: 12px 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 12px 12px 0 0;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s ease;
  font-size: 0.875rem;
  letter-spacing: 0.025em;
  position: relative;
}

.tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.tab.active {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Table */
.table-container {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-primary);
  width: 100%;
}

table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-primary);
}

th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
}

th:hover {
  background: var(--bg-hover);
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.05);
}

/* Badges */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  display: inline-block;
}

.badge.enterprise { 
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a1a;
  font-weight: 700;
}
.badge.premium { 
  background: linear-gradient(135deg, #a78bfa, #8b5cf6);
  color: white;
  font-weight: 700;
}
.badge.standard { 
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
  color: white;
  font-weight: 700;
}
.badge.basic {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}
.badge.ultimate {
  background: linear-gradient(135deg, #f472b6, #ec4899);
  color: white;
  font-weight: 700;
}
.badge.student {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: white;
  font-weight: 700;
}
.badge.active { 
  background: rgba(16, 185, 129, 0.3);
  color: #34d399;
  border: 1px solid #34d399;
  font-weight: 700;
}
.badge.expired { 
  background: rgba(239, 68, 68, 0.3);
  color: #f87171;
  border: 1px solid #f87171;
  font-weight: 700;
}
.badge.inactive { 
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}

/* License Key */
.license-key {
  font-family: 'Courier New', monospace;
  background: var(--bg-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--primary-light);
  font-weight: 500;
  display: inline-block;
  border: 1px solid var(--border-primary);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  backdrop-filter: blur(8px);
}

/* Specific styling for tier modal */
#tierModal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.7) !important;
  z-index: 1000 !important;
  backdrop-filter: blur(8px) !important;
}

#tierModal .modal-content {
  background: var(--bg-secondary) !important;
  margin: 50px auto !important;
  padding: 36px !important;
  border-radius: 24px !important;
  max-width: 800px !important;
  max-height: 90vh !important;
  overflow-y: auto !important;
  border: 1px solid var(--border-primary) !important;
  box-shadow: var(--shadow-xl) !important;
  color: var(--text-primary) !important;
}

#tierModal h2 {
  color: var(--text-primary) !important;
}

#tierModal .form-group label {
  color: var(--text-primary) !important;
}

#tierModal .form-group input,
#tierModal .form-group select,
#tierModal .form-group textarea {
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border: 2px solid var(--border-primary) !important;
}

#tierModal .form-group input:focus,
#tierModal .form-group select:focus,
#tierModal .form-group textarea:focus {
  border-color: var(--primary-color) !important;
  background: var(--bg-tertiary) !important;
}

#tierModal small {
  color: var(--text-muted) !important;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 24px;
  padding: 36px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s ease;
  border: 1px solid var(--border-primary);
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  color: var(--text-primary);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.close-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: rotate(90deg);
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid;
}

.alert.success {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: #10b981;
}

.alert.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: #ef4444;
}

.alert.info {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-color: #3b82f6;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 72px;
  margin-bottom: 24px;
  color: var(--text-disabled);
  opacity: 0.3;
}

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-primary);
  border-radius: 50%;
  border-top: 2px solid var(--primary-color);
  animation: spin 1s linear infinite;
}

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

/* Filters */
.filters {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  width: 100%;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-primary);
}

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

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

.setting-description {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 52px;
  height: 26px;
  background: var(--bg-tertiary);
  border-radius: 26px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid var(--border-primary);
}

.toggle.active {
  background: var(--primary-gradient);
  border-color: transparent;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle.active::after {
  left: 28px;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--bg-hover);
}

/* Large Screens */
@media (min-width: 1920px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .settings-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .container {
    padding: 40px;
  }
  
  .card {
    padding: 40px;
  }
}

@media (min-width: 2560px) {
  .stats-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .settings-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .container {
    padding: 48px;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 16px;
    padding: 0 16px;
  }
  
  .container {
    padding: 16px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .filters {
    flex-direction: column;
  }
  
  .user-info {
    order: -1;
  }
  
  th, td {
    padding: 12px;
    font-size: 14px;
  }
  
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  
  .tab {
    white-space: nowrap;
  }
}

/* Text Contrast Improvements */
td {
  color: var(--text-primary) !important;
}

th {
  color: var(--text-secondary) !important;
}

.form-group label {
  color: var(--text-primary) !important;
}

.form-group small {
  color: var(--text-muted) !important;
}

/* Ensure all text in cards is readable */
.card * {
  color: inherit;
}

.modal-content * {
  color: inherit;
}

/* Fix any remaining low contrast text */
p, span, div, label {
  color: var(--text-primary);
}

small, .small {
  color: var(--text-muted) !important;
}

/* Override any hardcoded gray colors */
[style*="color: #666"],
[style*="color: #6b7280"],
[style*="color: #718096"],
[style*="color: #2d3748"] {
  color: var(--text-primary) !important;
}

[style*="color: #a0aec0"] {
  color: var(--text-secondary) !important;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

.slide-up {
  animation: slideUp 0.3s ease;
}