/* ══════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:       #c8a96e;
  --gold-dark:  #a8893e;
  --dark:       #1a1a2e;
  --dark2:      #16213e;
  --surface:    #0f3460;
  --surface2:   #1a1a4e;
  --text:       #e8e8f0;
  --text-muted: #9999bb;
  --red:        #e05555;
  --green:      #4caf80;
  --radius:     12px;
  --shadow:     0 8px 32px rgba(0,0,0,.45);
}

html, body {
  height: 100%;
  font-family: 'Cairo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--dark);
  color: var(--text);
  font-size: 16px;
  direction: rtl;
}

/* ══════════════════════════════════════════
   PAGE UTILITY
══════════════════════════════════════════ */
.page { min-height: 100vh; }
.page.hidden { display: none !important; }
.page.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ══════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════ */
#loginPage {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, var(--dark2) 50%, #0d0d2b 100%);
  padding: 24px 16px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(200,169,110,.2);
}

.logo-area { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 52px; line-height: 1; margin-bottom: 8px; }
.logo-area h1 { font-size: 1.6rem; font-weight: 700; color: var(--gold); }
.logo-area .subtitle { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }

/* ══════════════════════════════════════════
   FIELD GROUPS
══════════════════════════════════════════ */
.field-group { margin-bottom: 20px; }
.field-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.required { color: var(--red); }

input[type="text"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
  appearance: none;
}
input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder { color: var(--text-muted); }
input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,169,110,.2);
}
textarea { resize: vertical; min-height: 120px; }

/* Select arrow — left side for RTL */
.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾';
  position: absolute;
  left: 14px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  pointer-events: none;
}
select option { background: var(--dark2); color: var(--text); }

/* Password toggle — left side for RTL */
.password-wrap { position: relative; }
.password-wrap input { padding-left: 48px; padding-right: 14px; }
.toggle-pass {
  position: absolute;
  left: 12px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: .7;
  transition: opacity .2s;
}
.toggle-pass:hover { opacity: 1; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #1a1a2e;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  margin-top: 8px;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ══════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════ */
.error-msg {
  background: rgba(224,85,85,.15);
  border: 1px solid rgba(224,85,85,.4);
  color: #ff8a8a;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .9rem;
  margin-bottom: 12px;
}
.success-msg {
  background: rgba(76,175,128,.15);
  border: 1px solid rgba(76,175,128,.4);
  color: #80ffb8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .9rem;
  margin-bottom: 12px;
}

/* ══════════════════════════════════════════
   TOP BAR
══════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 12px 20px;
  border-bottom: 1px solid rgba(200,169,110,.25);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-info { display: flex; flex-direction: column; gap: 2px; }
.topbar-name { font-weight: 700; font-size: .95rem; color: var(--text); }
.topbar-role {
  font-size: .75rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.btn-logout {
  background: rgba(224,85,85,.15);
  border: 1px solid rgba(224,85,85,.35);
  color: #ff8a8a;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-logout:hover { background: rgba(224,85,85,.3); }

/* ══════════════════════════════════════════
   MAIN FORM
══════════════════════════════════════════ */
.form-container {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 48px;
}
.form-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 24px;
}

/* ══════════════════════════════════════════
   CAPTURE AREA
══════════════════════════════════════════ */
.capture-area {
  border: 2px dashed rgba(200,169,110,.4);
  border-radius: var(--radius);
  padding: 20px;
  background: rgba(255,255,255,.03);
}
.capture-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-capture, .btn-browse {
  flex: 1;
  min-width: 140px;
  padding: 14px 10px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid;
  transition: background .2s, transform .1s;
}
.btn-capture {
  background: rgba(200,169,110,.15);
  border-color: rgba(200,169,110,.5);
  color: var(--gold);
}
.btn-capture:hover { background: rgba(200,169,110,.28); }
.btn-browse {
  background: rgba(100,160,255,.12);
  border-color: rgba(100,160,255,.4);
  color: #88c0ff;
}
.btn-browse:hover { background: rgba(100,160,255,.22); }
.btn-capture:active, .btn-browse:active { transform: scale(.97); }

.preview-area { margin-top: 16px; text-align: center; position: relative; }
#previewImg {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  border: 1px solid rgba(200,169,110,.3);
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.preview-file {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: .9rem;
  color: var(--text-muted);
  word-break: break-all;
}
.btn-remove {
  display: inline-block;
  margin-top: 10px;
  background: rgba(224,85,85,.15);
  border: 1px solid rgba(224,85,85,.35);
  color: #ff8a8a;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-remove:hover { background: rgba(224,85,85,.3); }
.btn-send { margin-top: 8px; font-size: 1.05rem; }

/* ══════════════════════════════════════════
   CC EMAIL FIELD
══════════════════════════════════════════ */
.cc-box { display: flex; gap: 8px; flex-direction: column; }

.cc-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 48px;
  cursor: text;
  transition: border-color .2s, box-shadow .2s;
}
.cc-chips-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,169,110,.2);
}
.cc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(200,169,110,.18);
  border: 1px solid rgba(200,169,110,.45);
  color: var(--gold);
  border-radius: 20px;
  padding: 3px 10px 3px 6px;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
}
.cc-chip span { overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.cc-chip-remove {
  background: none;
  border: none;
  color: var(--gold);
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
  padding: 0;
  opacity: .7;
  transition: opacity .15s;
  flex-shrink: 0;
}
.cc-chip-remove:hover { opacity: 1; }
.cc-chips-wrap input[type="email"] {
  flex: 1;
  min-width: 160px;
  background: none;
  border: none;
  outline: none;
  box-shadow: none;
  padding: 4px 0;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}
.cc-chips-wrap input[type="email"]::placeholder { color: var(--text-muted); }
.btn-cc-add {
  align-self: flex-end;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(200,169,110,.45);
  background: rgba(200,169,110,.15);
  color: var(--gold);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.btn-cc-add:hover { background: rgba(200,169,110,.3); }
.field-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (min-width: 600px) {
  #mainPage { background: var(--dark2); }
  .form-container {
    background: var(--surface);
    border-radius: var(--radius);
    margin-top: 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(200,169,110,.15);
  }
}
