/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --primary-purple:   #96216C;
  --secondary-teal:   #00B1B8;
  --highlight-yellow: #FFDD1A;
  --text-dark:        #24262D;
  --bg-light:         #F4F6F9;
  --white:            #ffffff;
  --border-color:     #e5e7eb;
  --hover-bg:         #FDF4F9;
  --success-color:    #00B1B8;
  --error-color:      #dc2626;
  --shadow-sm:        0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md:        0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg:        0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* ── Base ─────────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
  direction: ltr;
  overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-image {
  height: 50px;
  width: auto;
  object-fit: contain;
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.header-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-purple);
  line-height: 1.2;
}

.header-subtitle {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--secondary-teal);
}

/* ── User section (header right) ─────────────────────────────────────────── */
.user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dark);
  opacity: 0.75;
}

.logout-btn {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-purple);
  text-decoration: none;
  padding: 0.35rem 0.9rem;
  border: 1.5px solid var(--primary-purple);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--primary-purple);
  color: var(--white);
}

/* ── Main container ───────────────────────────────────────────────────────── */
.main-container {
  margin-top: 90px;
  padding: 2rem;
  min-height: calc(100vh - 90px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Processor card ───────────────────────────────────────────────────────── */
.processor-card {
  background: white;
  border-radius: 20px;
  padding: 3rem;
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.processor-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--primary-purple), var(--secondary-teal));
}

.welcome-section {
  text-align: center;
  margin-bottom: 2rem;
}

.main-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-purple);
  margin-bottom: 0.75rem;
}

.description {
  color: var(--text-dark);
  font-size: 1rem;
  max-width: 700px;
  margin: 0 auto;
  opacity: 0.8;
}

/* ── Upload area ──────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  background: var(--bg-light);
  text-align: center;
  margin-bottom: 1rem;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--secondary-teal);
  background-color: var(--hover-bg);
  transform: translateY(-2px);
}

.upload-area input[type="file"] {
  position: absolute;
  width: 100%; height: 100%;
  top: 0; left: 0;
  opacity: 0;
  cursor: pointer;
}

.card-icon {
  width: 70px; height: 70px;
  border-radius: 50%;
  background: var(--white);
  color: var(--primary-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.card-desc { color: #666; font-size: 0.95rem; }

.card-hint {
  font-size: 0.8rem;
  color: #999;
  margin-top: 0.4rem;
}

/* ── File list ────────────────────────────────────────────────────────────── */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}

.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-dark);
}

.file-item-size {
  color: #888;
  white-space: nowrap;
  font-size: 0.8rem;
}

.file-remove-btn {
  background: none;
  border: none;
  color: #aaa;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 0.2rem;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

.file-remove-btn:hover { color: var(--error-color); }

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-container {
  margin-top: 1rem;
  text-align: left;
  display: none;
  direction: ltr;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-dark);
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-bar-bg {
  background-color: var(--border-color);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar {
  height: 100%;
  background-color: var(--secondary-teal);
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 4px;
}

.progress-bar.indeterminate {
  width: 50%;
  animation: moveIndeterminate 1.5s infinite linear;
}

@keyframes moveIndeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* ── Options section ──────────────────────────────────────────────────────── */
.options-section {
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.option-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.language-select {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dark);
  background: var(--white);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.language-select:focus {
  border-color: var(--primary-purple);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary-purple);
  cursor: pointer;
  flex-shrink: 0;
}

.edit-code-btn {
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--secondary-teal);
  background: none;
  border: 1.5px solid var(--secondary-teal);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.edit-code-btn:hover {
  background: var(--secondary-teal);
  color: var(--white);
}

/* ── Result actions ───────────────────────────────────────────────────────── */
.result-actions {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

.result-secondary {
  display: flex;
  gap: 0.6rem;
}

.btn-result {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0.75rem 1rem;
  border: none;
}

.btn-download-result {
  width: 100%;
  background: var(--primary-purple);
  color: var(--white);
}

.btn-download-result:hover:not(:disabled) {
  background: #7a1a57;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px rgba(150, 33, 108, 0.35);
}

.btn-download-result:disabled {
  background: #c8a0bc;
  cursor: default;
}

.btn-reset-result {
  flex: 1;
  background: var(--bg-light);
  color: #666;
  border: 1.5px solid var(--border-color) !important;
}

.btn-reset-result:hover {
  background: var(--border-color);
  color: var(--text-dark);
}

/* ── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--white);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-wide {
  max-width: 780px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 0.15rem;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: #888;
}

.modal-subtitle code {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  font-size: 0.75rem;
  color: var(--primary-purple);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #aaa;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.btn-text-muted {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: #aaa;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s;
}

.btn-text-muted:hover { color: #666; }

.btn-save {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--white);
  background: var(--primary-purple);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.4rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-save:hover { background: #7a1a57; }

/* ── Code textarea (used in code editor modal) ────────────────────────────── */
.code-textarea {
  width: 100%;
  height: 55vh;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 0.85rem;
  border: 1.5px solid #444;
  border-radius: 10px;
  background: #1e1e2e;
  color: #cdd6f4;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
  box-sizing: border-box;
}

.code-textarea:focus { border-color: var(--secondary-teal); }

/* ── Primary button ───────────────────────────────────────────────────────── */
.primary-btn {
  background: var(--primary-purple);
  color: white;
  border: none;
  padding: 1rem 3rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  font-family: inherit;
}

.primary-btn:hover {
  background: #7a1a57;
  transform: translateY(-2px);
  box-shadow: 0 10px 20px -5px rgba(150, 33, 108, 0.3);
}

.primary-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-light);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
}

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 6px;
  background: linear-gradient(90deg, var(--primary-purple), var(--secondary-teal));
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.login-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.login-divider {
  height: 1px;
  background: var(--border-color);
  margin-bottom: 1.5rem;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-purple);
  margin-bottom: 0.5rem;
}

.login-desc {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.75rem;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: var(--white);
  color: var(--text-dark);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border: 1.5px solid var(--border-color);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.google-btn:hover {
  border-color: #aaa;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
