/* -------------------------------------------------------------
 * LEXICOUNT PREMIUM STYLESHEET
 * Author: Antigravity
 * Description: Sleek, Glassmorphism-inspired, responsive layout.
 * ------------------------------------------------------------- */

/* Custom Fonts & Variable Definitions */
:root {
  /* Common Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Shared values */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.12);
  --max-width: 1400px;
}

/* Light Theme Variables */
body.light-theme {
  --bg-app: hsl(220, 30%, 96%);
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-solid: hsl(0, 0%, 100%);
  --bg-input: rgba(255, 255, 255, 0.9);
  --text-primary: hsl(222, 47%, 12%);
  --text-secondary: hsl(215, 20%, 45%);
  --text-muted: hsl(215, 15%, 65%);
  --border-color: rgba(15, 23, 42, 0.08);
  --border-focus: hsl(263, 85%, 55%);
  
  --primary-color: hsl(263, 85%, 55%);
  --primary-glow: rgba(139, 92, 246, 0.2);
  --secondary-color: hsl(192, 85%, 45%);
  --secondary-glow: rgba(6, 182, 212, 0.2);
  --accent-success: hsl(142, 70%, 42%);
  --accent-danger: hsl(350, 75%, 50%);
  
  --scrollbar-thumb: rgba(15, 23, 42, 0.15);
  --scrollbar-track: rgba(15, 23, 42, 0.03);
  
  --glass-glow: linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 100%);
}

/* Dark Theme Variables (Default) */
body.dark-theme {
  --bg-app: hsl(222, 47%, 7%);
  --bg-card: rgba(17, 24, 39, 0.5);
  --bg-card-solid: hsl(222, 47%, 11%);
  --bg-input: rgba(15, 23, 42, 0.6);
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 72%);
  --text-muted: hsl(215, 12%, 48%);
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: hsl(263, 90%, 65%);
  
  --primary-color: hsl(263, 90%, 65%);
  --primary-glow: rgba(139, 92, 246, 0.35);
  --secondary-color: hsl(190, 90%, 50%);
  --secondary-glow: rgba(6, 182, 212, 0.35);
  --accent-success: hsl(142, 72%, 50%);
  --accent-danger: hsl(350, 80%, 60%);
  
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-track: rgba(255, 255, 255, 0.02);
  
  --glass-glow: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.005) 100%);
}

/* Base resets & styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Background ambient glow effect */
body::before {
  content: '';
  position: fixed;
  top: -10%;
  left: -10%;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
}

body::after {
  content: '';
  position: fixed;
  bottom: -10%;
  right: -10%;
  width: 50%;
  height: 50%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--secondary-glow) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-pill);
}

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

/* Glassmorphism Panel Template */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  background-image: var(--glass-glow);
  transition: transform var(--transition-fast), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

/* Common Layout Components */
button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition: all var(--transition-fast);
}

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

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

/* HEADER STYLING */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: rgba(15, 23, 42, 0.01);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: border-color var(--transition-normal);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 24px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  color: var(--primary-color);
  filter: drop-shadow(0 0 8px var(--primary-glow));
  animation: logo-spin 10s linear infinite;
}

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

.logo-text {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-text span {
  color: var(--primary-color);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Bilingual switcher */
.lang-toggle-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 3px;
  display: flex;
  gap: 2px;
}

.lang-btn {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Theme Switcher Button */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.05);
}

body.dark-theme .sun-icon { display: block; }
body.dark-theme .moon-icon { display: none; }
body.light-theme .sun-icon { display: none; }
body.light-theme .moon-icon { display: block; }

/* Icon Button Style */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  position: relative;
}

.icon-btn:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: scale(1.05);
}

/* Tooltip implementation */
.tooltip-btn {
  position: relative;
}

.tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: -36px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-card-solid);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition-fast), bottom var(--transition-fast);
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.tooltip-btn:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
  bottom: -44px;
}

/* MAIN LAYOUT */
.app-main {
  flex: 1;
  padding: 32px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.main-grid-container {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

/* COLUMN 1: Text Editor Workspace */
.editor-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.editor-card {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  overflow: hidden;
  border-color: var(--border-color);
}

.editor-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 20px var(--primary-glow);
}

/* Toolbar styling */
.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.05);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
  margin: 0 4px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-input);
}

.tool-btn.icon-btn-only {
  padding: 8px 10px;
}

.tool-btn.danger-hover:hover {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.1);
}

.tool-btn.recording {
  background: var(--accent-danger) !important;
  color: white !important;
  border-color: var(--accent-danger) !important;
  animation: mic-pulse 1.5s infinite;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

@keyframes mic-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Textarea styling */
.textarea-wrapper {
  position: relative;
  flex: 1;
  display: flex;
}

#textInput {
  width: 100%;
  min-height: 380px;
  padding: 20px;
  background: transparent;
  border: none;
  resize: vertical;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.65;
  box-sizing: border-box;
}

#textInput::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

/* Info Bar under editor */
.editor-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.05);
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.autosave-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.7;
}

.autosave-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-success);
}

.autosave-indicator.saving .autosave-dot {
  background-color: var(--primary-color);
  animation: logo-spin 1s linear infinite;
  border: 1px dashed white;
}

/* Goals Settings Card */
.target-card {
  padding: 24px;
}

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

.card-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.accent-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.1);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.accent-badge.active-badge {
  background: var(--primary-glow);
  color: var(--primary-color);
  border-color: var(--primary-color);
}

.accent-badge.complete-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
  border-color: var(--accent-success);
}

.target-setup {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 120px;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.input-group select,
.input-group input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.input-group select:focus,
.input-group input:focus {
  border-color: var(--border-focus);
}

.target-progress-container {
  display: flex;
  align-items: center;
  gap: 24px;
  background: rgba(15, 23, 42, 0.03);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  animation: fade-in 0.3s ease;
}

.circular-progress-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bar {
  stroke-dasharray: 251.2; /* 2 * PI * r (r=40) */
  stroke-dashoffset: 251.2;
  transition: stroke-dashoffset 0.35s;
  transform-origin: 50% 50%;
}

.progress-text {
  position: absolute;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.progress-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-details span {
  font-size: 0.9rem;
  font-weight: 500;
}

.progress-bar-flat-wrapper {
  width: 100%;
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-flat {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-radius: var(--radius-pill);
  transition: width 0.35s;
}

/* COLUMN 2: Stats & Tabs Dashboard */
.analytics-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

/* Stats Dashboard Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
}

.stat-widget {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-widget:hover {
  transform: translateY(-4px);
  border-color: var(--primary-color);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-glow);
  color: var(--primary-color);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.stat-widget:nth-child(even) .stat-icon-wrapper {
  background: var(--secondary-glow);
  color: var(--secondary-color);
}

.stat-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

/* Tabs Container Card */
.tabs-card {
  padding: 0;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: rgba(15, 23, 42, 0.05);
  border-bottom: 1px solid var(--border-color);
}

.tab-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.tab-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-link.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: var(--bg-card);
}

.tab-icon {
  flex-shrink: 0;
}

.tab-content {
  display: none;
  padding: 24px;
  animation: fade-in 0.35s ease;
}

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

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* TAB 1: READABILITY CONTENT */
.readability-flex-container {
  display: flex;
  gap: 24px;
  align-items: center;
}

.flesch-gauge-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gauge-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-ring {
  transform: rotate(-90deg);
}

.gauge-ring-bar {
  stroke-dasharray: 314.15; /* 2 * PI * r (r=50) */
  stroke-dashoffset: 314.15;
  transition: stroke-dashoffset 0.4s ease-out;
  transform-origin: 50% 50%;
}

.gauge-value {
  position: absolute;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
}

.gauge-caption {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.readability-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.readability-info h4 {
  font-size: 1.1rem;
  font-weight: 700;
}

.small-text-dimmed {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.readability-stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.readability-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.readability-item span:first-child {
  color: var(--text-secondary);
}

.bold {
  font-weight: 700;
  color: var(--text-primary);
}

.sentiment-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.sentiment-pill.neutral {
  background-color: var(--border-color);
  color: var(--text-secondary);
}

.sentiment-pill.positive {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

.sentiment-pill.negative {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
}

/* TAB 2: KEYWORDS TABLE */
.keywords-toolbar {
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  accent-color: var(--primary-color);
}

.keyword-list-wrapper {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: rgba(15, 23, 42, 0.03);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
}

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

.empty-table-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
  font-style: italic;
}

/* Keyword progress indicator in table cell */
.density-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.density-bar-wrapper {
  width: 60px;
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.density-bar {
  height: 100%;
  background: var(--primary-color);
  border-radius: var(--radius-pill);
}

/* TAB 3: TEXT UTILITIES */
.utilities-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.utility-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.utility-group h4 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buttons-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.action-btn {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-align: center;
}

.action-btn:hover {
  background: var(--bg-card);
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 2px 8px var(--primary-glow);
}

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

.action-btn.primary-btn:hover {
  background: var(--border-focus);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.find-replace-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.find-replace-form input {
  flex: 1;
  min-width: 100px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

.find-replace-form input:focus {
  border-color: var(--border-focus);
}

.find-replace-form button {
  white-space: nowrap;
}

/* TAB 4: CHARTS */
.charts-toolbar {
  margin-bottom: 16px;
}

.charts-toolbar select {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}

.chart-canvas-container {
  position: relative;
  width: 100%;
  height: 240px;
}

/* SIDE DRAWER: SESSION HISTORY */
.side-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  pointer-events: none;
}

.side-drawer[aria-hidden="false"] {
  pointer-events: auto;
}

.drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.side-drawer[aria-hidden="false"] .drawer-overlay {
  opacity: 1;
}

.drawer-content {
  position: absolute;
  top: 0;
  right: -380px;
  width: 380px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-card-solid);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: right var(--transition-normal);
}

.side-drawer[aria-hidden="false"] .drawer-content {
  right: 0;
}

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

.drawer-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-btn {
  color: var(--text-secondary);
  display: grid;
  place-items: center;
}

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

.drawer-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.drafts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.draft-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-fast);
}

.draft-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.draft-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.draft-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
}

.draft-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.draft-action-btn {
  padding: 4px;
  color: var(--text-secondary);
  border-radius: 4px;
}

.draft-action-btn:hover {
  background: var(--bg-card);
  color: var(--primary-color);
}

.draft-action-btn.delete-btn:hover {
  color: var(--accent-danger);
  background: rgba(239, 68, 68, 0.1);
}

.draft-excerpt {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.draft-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.empty-drawer-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 40px 0;
  font-style: italic;
}

/* DROPDOWN MENU */
.dropdown-wrapper {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 15;
  animation: fade-in 0.15s ease;
}

.dropdown-menu.show {
  display: flex;
  flex-direction: column;
  padding: 4px;
}

.dropdown-item {
  padding: 8px 12px;
  font-size: 0.8rem;
  text-align: left;
  border-radius: 4px;
  color: var(--text-secondary);
}

.dropdown-item:hover {
  background: var(--bg-input);
  color: var(--primary-color);
}

/* EDUCATIONAL CONTENT SECTION */
.seo-content-section {
  max-width: var(--max-width);
  margin: 60px auto 20px auto;
  padding: 0 24px;
  border-top: 1px solid var(--border-color);
  padding-top: 60px;
}

.seo-container h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 32px;
  text-align: center;
  letter-spacing: -0.5px;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.seo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: border-color var(--transition-normal);
}

.seo-card:hover {
  border-color: var(--primary-glow);
}

.seo-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--primary-color);
}

.seo-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ACCORDION */
.seo-accordion {
  max-width: 800px;
  margin: 40px auto 0 auto;
}

.seo-accordion h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.accordion-item {
  border-bottom: 1px solid var(--border-color);
}

.accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
}

.accordion-header:hover {
  color: var(--primary-color);
}

.accordion-arrow {
  transition: transform var(--transition-normal);
  color: var(--text-secondary);
}

.accordion-item.active .accordion-arrow {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.accordion-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

.accordion-panel p {
  padding-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* FOOTER */
.app-footer {
  background: rgba(15, 23, 42, 0.02);
  border-top: 1px solid var(--border-color);
  padding: 30px 24px;
  margin-top: 60px;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.footer-logo .logo-icon {
  animation: none;
}

.app-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  gap: 20px;
  font-size: 0.8rem;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  .main-grid-container {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  body {
    font-size: 15px;
  }
  
  .app-main {
    padding: 16px 12px;
  }
  
  .header-container {
    padding: 12px 16px;
  }
  
  .editor-toolbar {
    padding: 8px;
    gap: 8px;
  }
  
  .toolbar-group {
    gap: 6px;
  }
  
  .toolbar-divider {
    display: none;
  }
  
  .tool-btn {
    padding: 6px 10px;
    gap: 0;
  }
  
  .btn-label {
    display: none; /* Hide button text on small screens, icons only */
  }
  
  .tool-btn.icon-btn-only {
    padding: 6px 8px;
  }
  
  .seo-container h2 {
    font-size: 1.5rem;
  }
  
  .drawer-content {
    width: 100%;
    right: -100%;
  }
}

/* Right-to-Left (RTL) Layout overrides for Arabic */
html[dir="rtl"] {
  direction: rtl;
}

html[dir="rtl"] body {
  text-align: right;
}

html[dir="rtl"] .nav-controls {
  flex-direction: row-reverse;
}

html[dir="rtl"] .editor-toolbar {
  flex-direction: row-reverse;
}

html[dir="rtl"] .tool-btn {
  flex-direction: row-reverse;
}

html[dir="rtl"] .drawer-content {
  right: auto;
  left: -380px;
  border-left: none;
  border-right: 1px solid var(--border-color);
  transition: left var(--transition-normal);
}

html[dir="rtl"] .side-drawer[aria-hidden="false"] .drawer-content {
  left: 0;
  right: auto;
}

html[dir="rtl"] .dropdown-menu {
  left: 0;
  right: auto;
}

html[dir="rtl"] .dropdown-item {
  text-align: right;
}

html[dir="rtl"] .accordion-header {
  text-align: right;
  flex-direction: row-reverse;
}

html[dir="rtl"] .checkbox-label {
  flex-direction: row-reverse;
}

html[dir="rtl"] .data-table {
  text-align: right;
}

html[dir="rtl"] .density-cell {
  flex-direction: row-reverse;
}

html[dir="rtl"] .readability-flex-container {
  flex-direction: row-reverse;
}

html[dir="rtl"] .readability-stats-list {
  padding-left: 0;
  padding-right: 12px;
}

html[dir="rtl"] .readability-item {
  flex-direction: row-reverse;
}

@media (max-width: 768px) {
  html[dir="rtl"] .drawer-content {
    right: auto;
    left: -100%;
  }
  html[dir="rtl"] .side-drawer[aria-hidden="false"] .drawer-content {
    left: 0;
    right: auto;
  }
}

/* RESPONSIVE LAYOUT ENHANCEMENTS */
.lang-select-mobile {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: all var(--transition-fast);
}

.lang-select-mobile:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.lang-select-mobile:focus {
  border-color: var(--border-focus);
}

html[dir="rtl"] .lang-select-mobile {
  background-position: left 10px center;
  padding-right: 12px;
  padding-left: 28px;
}

@media (max-width: 768px) {
  .lang-toggle-wrapper {
    display: none;
  }
  .lang-select-mobile {
    display: block;
  }
}

@media (max-width: 600px) {
  .tabs-header {
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    justify-content: flex-start;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .tabs-header::-webkit-scrollbar {
    display: none;
  }
  .tab-link {
    flex: 0 0 auto;
    padding: 14px 18px;
  }
}

@media (max-width: 480px) {
  .logo-text {
    font-size: 1.05rem !important;
  }
  .logo-icon {
    width: 20px !important;
    height: 20px !important;
  }
  .header-container {
    padding: 10px 12px !important;
  }
  .nav-controls {
    gap: 6px !important;
  }
  .theme-toggle, .icon-btn {
    width: 32px !important;
    height: 32px !important;
  }
  .theme-toggle svg, .icon-btn svg {
    width: 18px !important;
    height: 18px !important;
  }
  .lang-select-mobile {
    padding: 4px 8px !important;
    padding-right: 22px !important;
    font-size: 0.7rem !important;
    background-position: right 6px center !important;
  }
  html[dir="rtl"] .lang-select-mobile {
    background-position: left 6px center !important;
    padding-right: 8px !important;
    padding-left: 22px !important;
  }
  .app-main {
    padding: 12px 8px !important;
  }
  .editor-toolbar {
    padding: 6px !important;
    gap: 6px !important;
  }
  .toolbar-group {
    gap: 4px !important;
  }
  .tool-btn {
    padding: 6px 6px !important;
  }
  .readability-flex-container {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  .readability-stats-list {
    width: 100%;
  }
  .find-replace-form input {
    flex: 1 0 100%;
  }
  .find-replace-form button {
    width: 100%;
  }
  .seo-grid {
    grid-template-columns: 1fr !important;
  }
  .utilities-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 360px) {
  .logo-text {
    font-size: 0.95rem !important;
  }
  .logo-icon {
    width: 18px !important;
    height: 18px !important;
  }
  .header-container {
    padding: 8px 8px !important;
  }
  .nav-controls {
    gap: 4px !important;
  }
  .theme-toggle, .icon-btn {
    width: 28px !important;
    height: 28px !important;
  }
  .theme-toggle svg, .icon-btn svg {
    width: 15px !important;
    height: 15px !important;
  }
  .lang-select-mobile {
    padding: 3px 6px !important;
    padding-right: 18px !important;
    font-size: 0.65rem !important;
    background-position: right 4px center !important;
  }
  html[dir="rtl"] .lang-select-mobile {
    background-position: left 4px center !important;
    padding-right: 6px !important;
    padding-left: 18px !important;
  }
  .editor-toolbar {
    padding: 4px !important;
    gap: 4px !important;
  }
  .toolbar-group {
    gap: 3px !important;
  }
  .tool-btn {
    padding: 4px 4px !important;
  }
  .tool-btn svg {
    width: 16px !important;
    height: 16px !important;
  }
}

@media (max-width: 400px) {
  .target-progress-container {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }
}
