/* =========================================
   Design System & Variables
   ========================================= */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --secondary: #10B981;
  --accent: #F59E0B;
  --surface-1: #ffffff;
  --surface-2: #F9FAFB;
  --surface-3: #F3F4F6;
  --text-main: #111827;
  --text-muted: #6B7280;
  --text-light: #9CA3AF;
  --border: #E5E7EB;
  
  --gradient-brand: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
  --gradient-dark: linear-gradient(to right, #0f172a, #1e293b);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.3);
  --radius-md: 12px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; color: var(--text-main); background-color: var(--surface-2); min-height: 100vh; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: 'Outfit', sans-serif; }

/* =========================================
   Layout & Navbar
   ========================================= */
.app-container { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.navbar {
  height: 70px; background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; z-index: 50; flex-shrink: 0; position: sticky; top: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--gradient-brand);
  color: white; display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.brand-text { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; background: var(--gradient-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.api-settings { display: flex; align-items: center; gap: 16px; }
.api-btn {
  background: var(--surface-3); border: 1px solid var(--border); padding: 8px 16px;
  border-radius: 24px; font-size: 13px; font-weight: 600; color: var(--text-main);
  cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; align-items: center; gap: 8px;
}
.api-btn:hover { background: var(--surface-1); border-color: var(--text-light); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.api-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #EF4444; }
.api-status-dot.active { background: #10B981; box-shadow: 0 0 8px #10B981; }

/* =========================================
   Main Content Area
   ========================================= */
.main-workspace {
  flex: 1; display: flex; padding: 24px; gap: 24px; overflow: hidden;
  background: radial-gradient(circle at top right, rgba(79, 70, 229, 0.03), transparent 40%),
              radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.03), transparent 40%);
}

/* Left Sidebar: Settings & Rules */
.sidebar {
  width: 340px; background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(20px);
  border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,0.5);
  box-shadow: var(--shadow-md); display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h3 { font-size: 16px; font-weight: 700; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 24px; }

.rule-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 16px; margin-bottom: 12px; transition: all 0.2s;
}
.rule-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.rule-title { font-size: 14px; font-weight: 600; color: var(--primary); display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.rule-desc { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Center Area: Upload & Result Viewer */
.center-panel {
  flex: 1; display: flex; flex-direction: column; gap: 24px; overflow: hidden;
}

/* Upload Box */
.upload-container {
  background: var(--surface-1); border: 2px dashed #CBD5E1; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; transition: all 0.3s; cursor: pointer; text-align: center;
  box-shadow: var(--shadow-sm); position: relative;
}
.upload-container:hover, .upload-container.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-icon { font-size: 48px; color: var(--primary); margin-bottom: 16px; transition: transform 0.3s cubic-bezier(0.4, 2, 0.2, 1); }
.upload-container:hover .upload-icon { transform: scale(1.1) translateY(-5px); }
.upload-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.upload-subtitle { font-size: 13px; color: var(--text-muted); max-width: 300px; line-height: 1.5; }

/* Flow State / Progress */
.glass-panel {
  background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(16px);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); padding: 24px; display: flex; flex-direction: column; flex: 1; min-height: 0;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.panel-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.panel-actions { display: flex; gap: 12px; }

.btn-action {
  background: var(--primary); color: white; border: none; padding: 10px 20px;
  border-radius: var(--radius-md); font-weight: 600; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: all 0.2s; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.btn-action:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3); }
.btn-action:disabled { background: #D1D5DB; cursor: not-allowed; box-shadow: none; }
.btn-outline {
  background: white; color: var(--text-main); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-light); }

/* Tab Navigation */
.tab-navigation {
  display: flex; gap: 16px; margin-top: 20px; border-bottom: 1px solid var(--border); padding-bottom: 8px; align-items: center; width: 100%;
}
.tab-wrapper { display: flex; align-items: center; gap: 6px; }
.tab-btn {
  background: none; border: none; padding: 6px 10px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; transition: all 0.2s; border-bottom: 2px solid transparent; display: flex; align-items: center; justify-content: center;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom: 2px solid var(--primary); }
.tab-checkbox { cursor: pointer; width: 14px; height: 14px; accent-color: var(--primary); }

/* Results Table */
.results-area { flex: 1; overflow-y: auto; }
.result-item {
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px;
  background: white; transition: all 0.2s; cursor: default;
}
.result-item.violation { border-left: 4px solid #EF4444; }
.result-item.warning { border-left: 4px solid #F59E0B; }
.result-item.passed { border-left: 4px solid #10B981; }

.r-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.r-rule { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 4px 8px; border-radius: 12px; font-weight: 600; text-transform: uppercase; }
.badge.violation { background: #FEE2E2; color: #DC2626; }
.badge.warning { background: #FEF3C7; color: #D97706; }
.badge.passed { background: #D1FAE5; color: #059669; }

.r-text { font-size: 13px; color: var(--text-main); display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.r-quote { font-family: monospace; font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 6px; color: var(--text-muted); border-left: 2px solid #CBD5E1; }
.r-comment { font-size: 13px; color: var(--primary-hover); font-weight: 500; display: flex; gap: 6px; align-items: flex-start; }

/* Translation Module */
.translation-split {
  display: flex; gap: 20px; height: 100%; min-height: 400px;
}
.source-pane, .target-pane {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: white; display: flex; flex-direction: column; overflow: hidden;
}
.pane-header {
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; color: var(--text-main); display: flex; justify-content: space-between;
}
.pane-content {
  flex: 1; padding: 16px; overflow-y: auto; font-size: 14px; line-height: 1.6;
}
.segment-block {
  display: block; margin-bottom: 16px; padding: 8px; border-radius: 6px;
  border-left: 3px solid transparent; transition: background 0.2s;
}
.segment-block:hover { background: var(--surface-2); cursor: pointer; border-left-color: #CBD5E1; }
.segment-block.active { background: var(--primary-light); border-left-color: var(--primary); }

/* Modals */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 100; align-items: center; justify-content: center; }
.modal-content { background: white; width: 440px; border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg); transform: scale(0.95); opacity: 0; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.modal-overlay.show { display: flex; }
.modal-overlay.show .modal-content { transform: scale(1); opacity: 1; }
.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 24px; color: var(--text-main); }
.input-grp { margin-bottom: 20px; }
.input-grp label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--text-muted); }
.input-grp input, .input-grp select {
  width: 100%; padding: 12px 16px; border-radius: var(--radius-md); border: 1px solid #CBD5E1; font-size: 14px;
  font-family: inherit; transition: all 0.2s; outline: none; background: var(--surface-2);
}
.input-grp input:focus, .input-grp select:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 32px; }

/* Animations */
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading-spin { animation: spin 1s linear infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94A3B8; }
