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

:root {
  --bg-main: #0B0F19;
  --bg-panel: rgba(20, 27, 45, 0.7);
  --bg-input: rgba(12, 17, 29, 0.9);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-focus: #5A67D8;
  --text-main: #F7FAFC;
  --text-muted: #A0AEC0;
  --text-accent: #63B3ED;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #2D3748;
  --secondary-hover: #4A5568;
  --danger: #E53E3E;
  --success: #319795;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --glass-border: rgba(255, 255, 255, 0.05);
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 10% 20%, rgba(90, 103, 216, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(49, 151, 149, 0.1) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 1440px;
  height: 90vh;
  min-height: 700px;
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 22, 38, 0.5);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--text-accent));
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-text p {
  font-size: 12px;
  color: var(--text-muted);
}

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(12, 17, 29, 0.5);
  padding: 6px 12px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.online {
  background-color: #48BB78;
  box-shadow: 0 0 8px #48BB78;
}

.status-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Main Workspace */
.app-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Panels */
.panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.config-panel {
  border-right: 1px solid var(--border-color);
  max-width: 600px;
  min-width: 450px;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.panel-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.panel-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Forms & Inputs */
.form-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  background: rgba(12, 17, 29, 0.2);
}

.form-section legend {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-accent);
  padding: 0 8px;
}

.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 14px;
}

.form-row .form-field {
  flex: 1;
  margin-bottom: 0;
}

.form-field {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-main);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.required {
  color: var(--danger);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.2s ease-in-out;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(90, 103, 216, 0.25);
}

textarea {
  resize: vertical;
}

/* Telco Cards Selection */
.telco-options {
  display: flex;
  gap: 14px;
  margin-top: 6px;
}

.telco-card {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.telco-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.telco-card-content {
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  transition: all 0.2s ease;
  background: rgba(12, 17, 29, 0.4);
}

.telco-card input[type="radio"]:checked + .telco-card-content {
  border-color: var(--primary);
  background: rgba(90, 103, 216, 0.15);
  box-shadow: 0 0 10px rgba(90, 103, 216, 0.2);
}

.telco-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  margin-bottom: 4px;
}

.telco-desc {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.telco-subform {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.sub-legend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-accent);
  margin-bottom: 12px;
  display: block;
}

.cli-regex-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6366F1);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover), #4F46E5);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

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

.btn-danger {
  background-color: rgba(229, 62, 98, 0.2);
  color: #FFA4A4;
  border: 1px solid rgba(229, 62, 98, 0.4);
}

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

.btn-xs {
  padding: 4px 8px;
  font-size: 10px;
  border-radius: 4px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 4px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* Right Panel: Previews */
.preview-panel {
  background: rgba(10, 15, 26, 0.8);
}

.tab-headers {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.preview-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(99, 179, 237, 0.15);
  color: var(--text-accent);
  padding: 4px 8px;
  border-radius: 4px;
}

.preview-body {
  padding: 0;
  position: relative;
}

.tab-content {
  display: none;
  height: 100%;
  flex-direction: column;
}

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

.file-name-bar {
  background: rgba(12, 17, 29, 0.4);
  padding: 10px 24px;
  font-size: 12px;
  font-family: monospace;
  color: var(--text-accent);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-content pre {
  margin: 0;
  padding: 24px;
  flex: 1;
  overflow: auto;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #E2E8F0;
  background: #090D16;
}

/* Excel Preview Styling */
.excel-preview-container {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: #0F172A;
}

.excel-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
}

.excel-table th, 
.excel-table td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 12px;
  text-align: left;
}

.excel-table th {
  background-color: rgba(30, 41, 59, 0.9);
  color: var(--text-main);
  font-weight: 600;
}

.excel-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Highlight replaced values in previews */
.highlight-val {
  background-color: rgba(246, 224, 94, 0.15);
  border-bottom: 1px dashed #D69E2E;
  color: #F6E05E;
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 500;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 30px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.success-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: rgba(49, 151, 149, 0.2);
  color: #319795;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px auto;
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 10px;
}

.modal-content p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.modal-content ul {
  text-align: left;
  list-style: none;
  margin-bottom: 24px;
  background: rgba(12, 17, 29, 0.4);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-content li {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-content li::before {
  content: "📁";
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  transform: translateY(150%);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

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

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

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

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

.count-badge {
  font-size: 11px;
  color: var(--text-accent);
  margin-top: 4px;
  display: block;
  text-align: right;
  opacity: 0.85;
}

/* Light Theme Variables */
body.light-theme {
  --bg-main: #F4F6F9;
  --bg-panel: rgba(255, 255, 255, 0.85);
  --bg-input: #FFFFFF;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-focus: #4F46E5;
  --text-main: #1F2937;
  --text-muted: #6B7280;
  --text-accent: #2563EB;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #E5E7EB;
  --secondary-hover: #D1D5DB;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
  --glass-border: rgba(0, 0, 0, 0.06);
}

body.light-theme {
  background-image: 
    radial-gradient(at 10% 20%, rgba(79, 70, 229, 0.04) 0px, transparent 50%),
    radial-gradient(at 90% 80%, rgba(49, 151, 149, 0.03) 0px, transparent 50%);
}

body.light-theme .app-header {
  background: rgba(255, 255, 255, 0.6);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .server-status {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .form-section {
  background: rgba(0, 0, 0, 0.015);
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-theme .preview-panel {
  background: #FAFBFD;
}

body.light-theme .tab-content pre {
  background: #F9FAFB;
  color: #111827;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-theme .file-name-bar {
  background: rgba(0, 0, 0, 0.02);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-theme .excel-preview-container {
  background: #FAFBFD;
}

body.light-theme .excel-table {
  background: #FFFFFF;
  border-color: rgba(0, 0, 0, 0.08);
  color: #1F2937;
}

body.light-theme .excel-table th {
  background-color: #F3F4F6;
  color: #1F2937;
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .excel-table td {
  border-color: rgba(0, 0, 0, 0.06);
}

body.light-theme .excel-table tr:hover {
  background-color: rgba(0, 0, 0, 0.015);
}

body.light-theme .highlight-val {
  background-color: rgba(245, 158, 11, 0.12);
  border-bottom: 1px dashed #D97706;
  color: #B45309;
}

body.light-theme .telco-card-content {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .telco-card input[type="radio"]:checked + .telco-card-content {
  background: rgba(79, 70, 229, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.08);
}

body.light-theme .btn-danger {
  background-color: rgba(229, 62, 98, 0.12);
  color: #DC2626;
  border-color: rgba(229, 62, 98, 0.2);
}

body.light-theme .btn-danger:hover {
  background-color: #DC2626;
  color: white;
}
