/* ========================================
   UnVanish Dashboard — Green Theme Stylesheet
   ======================================== */

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

:root {
  --bg-primary: #0a0a0a;
  --bg-surface: #1a1a1a;
  --bg-surface-hover: #222;
  --bg-surface-raised: #242424;
  --bg-input: #111;
  --accent: #25D366;
  --accent-hover: #2ee67e;
  --accent-dark: #128C7E;
  --accent-muted: rgba(37, 211, 102, 0.15);
  --accent-gradient: linear-gradient(135deg, #25D366, #128C7E);
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --text-muted: #555;
  --border: #333;
  --border-hover: #555;
  --border-focus: #25D366;
  --error: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.1);
  --success: #25D366;
  --success-bg: rgba(37, 211, 102, 0.1);
  --warning: #f0a030;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  direction: rtl;
}

/* ---------- Auth Pages ---------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: var(--bg-primary);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37, 211, 102, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(18, 140, 126, 0.04) 0%, transparent 50%);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-logo {
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: center;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
}

.auth-form {
  text-align: right;
}

.auth-error,
.auth-success {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  text-align: right;
}

.auth-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.auth-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(37, 211, 102, 0.2);
}

.auth-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* ---------- Phone Input ---------- */
.phone-input-group {
  margin-bottom: 1.25rem;
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 1.25rem;
  text-align: right;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: var(--font-family);
  transition: border-color var(--transition);
  direction: ltr;
  text-align: left;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input[name="name"] {
  direction: rtl;
  text-align: right;
}

.form-input[name="address"] {
  direction: rtl;
  text-align: right;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 211, 102, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-family);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: var(--accent-hover);
}

.link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Spinner ---------- */
.spinner {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-loader {
  display: inline-flex;
  align-items: center;
}

.btn.loading .btn-text {
  display: none;
}

.btn.loading .btn-loader {
  display: inline-flex;
}

/* ---------- OTP Input ---------- */
.verify-phone {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  letter-spacing: 0.05em;
  direction: ltr;
  display: inline-block;
}

.otp-group {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.otp-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-family);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.otp-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.otp-input.filled {
  border-color: var(--text-muted);
}

.verify-resend {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.resend-timer {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ---------- Dashboard Layout ---------- */
.dashboard-body {
  overflow: hidden;
}

.dashboard-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Mobile Header ---------- */
.dashboard-mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.mobile-menu-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.25rem;
}

.mobile-logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
}

/* ---------- Sidebar ---------- */
.dashboard-sidebar {
  width: 240px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  z-index: 60;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 1.25rem 1.25rem 1rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.sidebar-link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--accent-muted);
  color: var(--accent);
}

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

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
}

.sidebar-overlay.visible {
  display: block;
}

/* ---------- Main Content ---------- */
.dashboard-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-greeting {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

/* ---------- Cards ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 1.25rem 1.5rem;
}

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
}

.badge.trial {
  background: rgba(240, 160, 48, 0.15);
  color: var(--warning);
}

.badge.active {
  background: rgba(37, 211, 102, 0.15);
  color: var(--success);
}

.badge.inactive {
  background: var(--error-bg);
  color: var(--error);
}

/* ---------- Info Rows ---------- */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.info-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
}

/* ---------- Tables ---------- */
.table-container {
  margin-top: 1rem;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-primary);
}

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

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
}

.empty-state p {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

/* ---------- Page Placeholder ---------- */
.page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-secondary);
  min-height: 300px;
}

.page-placeholder h3 {
  margin-top: 1rem;
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.page-placeholder p {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  max-width: 400px;
}

/* ---------- Loading ---------- */
.page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  gap: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.page-error {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--error);
  font-size: 0.9rem;
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 900px) {
  .dashboard-sidebar {
    width: 220px;
  }

  .dashboard-topbar {
    padding: 0.9rem 1.25rem;
  }

  .dashboard-content {
    padding: 1.5rem;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 640px) {
  .auth-card {
    padding: 2rem 1.25rem;
  }

  .auth-title {
    font-size: 1.3rem;
  }

  .otp-input {
    width: 42px;
    height: 50px;
    font-size: 1.25rem;
  }

  .otp-group {
    gap: 0.4rem;
  }

  .dashboard-mobile-header {
    display: flex;
  }

  .dashboard-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    transform: translateX(100%);
    z-index: 60;
    width: 260px;
  }

  .dashboard-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .dashboard-main {
    margin-top: 56px;
  }

  .dashboard-topbar {
    padding: 0.75rem 1rem;
  }

  .page-title {
    font-size: 1rem;
  }

  .dashboard-content {
    padding: 1rem;
  }

  .user-greeting {
    display: none;
  }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

/* ---------- Legal Buttons & Modals ---------- */
.legal-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
  margin-bottom: 1.25rem;
}

.legal-btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-family);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

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

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.modal-overlay.active {
  display: flex;
}

.legal-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  max-width: 460px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.legal-modal h2 {
  color: var(--accent);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.legal-modal h3 {
  color: var(--warning);
  font-size: 0.95rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.legal-modal p {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.legal-modal ul {
  list-style: none;
  padding: 0;
  margin-bottom: 0.6rem;
}

.legal-modal ul li {
  font-size: 0.85rem;
  line-height: 1.8;
  color: var(--text-secondary);
  padding-right: 1.25rem;
  position: relative;
}

[dir="ltr"] .legal-modal ul li {
  padding-right: 0;
  padding-left: 1.25rem;
}

.legal-modal ul li::before {
  content: "\2022";
  position: absolute;
  right: 0;
  color: var(--accent);
}

[dir="ltr"] .legal-modal ul li::before {
  right: auto;
  left: 0;
}

.modal-close-btn {
  display: block;
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-family);
  cursor: pointer;
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  margin-top: 1.25rem;
  transition: background var(--transition);
}

.modal-close-btn:hover {
  background: var(--bg-surface-hover);
}

/* ---------- Language Toggle ---------- */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  padding: 2px;
  gap: 2px;
}

.lang-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-family);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

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

.lang-toggle-btn.active {
  background: var(--accent);
  color: #0a0a0a;
}

/* Auth pages: position toggle at top-right corner */
.auth-page .lang-toggle-wrap {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 10;
}

/* Dashboard: place toggle in topbar (left side, beside page title) */
.dashboard-topbar .lang-toggle-wrap {
  margin-inline-start: 0.75rem;
}

/* ---------- intl-tel-input Green Theme Overrides ---------- */
.iti {
  width: 100%;
}

.iti__flag-container {
  z-index: 4;
}

.iti__selected-flag {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px 0 0 10px;
  padding: 0 10px 0 12px;
}

.iti__selected-flag:hover,
.iti__selected-flag:focus {
  background: rgba(37, 211, 102, 0.08);
}

.iti__selected-dial-code {
  color: #e0e0e0;
  font-size: 16px;
  font-family: var(--font-family);
  font-weight: 400;
}

.iti__arrow {
  border-top: 4px solid #25D366;
  margin-left: 8px;
}

.iti__arrow--up {
  border-bottom: 4px solid #25D366;
  border-top: none;
}

.iti__country-list {
  background: #1a1a1a;
  border: 1px solid rgba(37, 211, 102, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  max-height: 300px;
  margin-top: 4px;
}

.iti__country {
  color: #e0e0e0;
  padding: 8px 12px;
}

.iti__country:hover,
.iti__country.iti__highlight {
  background: rgba(37, 211, 102, 0.15);
}

.iti__country-name {
  color: #c0c0c0;
}

.iti__dial-code {
  color: #888;
}

.iti__search-input {
  background: #111;
  border: 1px solid rgba(37, 211, 102, 0.2);
  border-radius: 8px;
  color: #e0e0e0;
  padding: 8px 12px;
  margin: 8px;
  width: calc(100% - 16px);
  font-size: 14px;
}

.iti__search-input:focus {
  border-color: #25D366;
  outline: none;
}

.iti__search-input::placeholder {
  color: #555;
}

.iti__divider {
  border-color: rgba(37, 211, 102, 0.1);
}

/* RTL: flag container on right, dial code margin */
[dir="rtl"] .iti__selected-flag {
  border-radius: 10px 0 0 10px;
}

[dir="rtl"] .iti__arrow {
  margin-left: 0;
  margin-right: 8px;
}

[dir="rtl"] .iti--separate-dial-code .iti__selected-dial-code {
  margin-left: 0;
  margin-right: 6px;
}

.iti__flag-box,
.iti__country-flag {
  margin-right: 8px;
}

/* Phone input: full LTR — flag on left, digits grow left-to-right */
.phone-input {
  background: #111 !important;
  border: 1px solid #333 !important;
  border-radius: 10px !important;
  color: #e0e0e0 !important;
  font-size: 16px;
  font-family: var(--font-family);
  font-weight: 400;
  width: 100%;
  direction: ltr;
  text-align: left;
  padding: 14px 16px 14px 95px !important;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.phone-input:focus {
  border-color: #25D366 !important;
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
  outline: none;
}

.phone-input::placeholder {
  color: #555;
}