/* ================================================
   Maily7 — Main Stylesheet v1.0
   Premium Temporary Email Platform
   ================================================ */

/* Google Fonts fallback (loaded via HTML <link>) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Cairo:wght@300;400;500;600;700&display=swap');

/* ================================================
   CSS Custom Properties
   ================================================ */
:root {
  --color-primary:      #0ea5e9;
  --color-primary-dark: #0284c7;
  --color-primary-light:#38bdf8;
  --color-secondary:    #06b6d4;

  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error:   #ef4444;
  --color-info:    #3b82f6;

  --surface-bg:     #f8fafc;
  --surface-card:   #ffffff;
  --surface-border: #e2e8f0;
  --surface-input:  #ffffff;
  --surface-hover:  #f1f5f9;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  --shadow-sm:  0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-md:  0 4px 6px -1px rgb(0 0 0 / .07), 0 2px 4px -2px rgb(0 0 0 / .05);
  --shadow-lg:  0 10px 15px -3px rgb(0 0 0 / .08), 0 4px 6px -4px rgb(0 0 0 / .05);
  --shadow-xl:  0 20px 25px -5px rgb(0 0 0 / .08), 0 8px 10px -6px rgb(0 0 0 / .04);
  --shadow-primary: 0 4px 20px -4px rgb(14 165 233 / .35);

  --header-height: 64px;
  --radius-sm:  .375rem;
  --radius-md:  .5rem;
  --radius-lg:  .75rem;
  --radius-xl:  1rem;
  --radius-2xl: 1.5rem;

  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

[data-theme="dark"], html.dark {
  --surface-bg:     #0f172a;
  --surface-card:   #1e293b;
  --surface-border: #334155;
  --surface-input:  #1e293b;
  --surface-hover:  #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .3), 0 2px 4px -2px rgb(0 0 0 / .2);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .3), 0 4px 6px -4px rgb(0 0 0 / .2);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .3s ease, color .3s ease;
}

/* Arabic font */
html[lang="ar"] body,
html[lang="ar"] * { font-family: 'Cairo', 'Inter', sans-serif !important; }

/* Logical properties for RTL/LTR */
html[dir="rtl"] .ms-auto { margin-inline-start: auto; }
html[dir="rtl"] .me-auto { margin-inline-end: auto; }

img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
ul, ol { list-style: none; }

/* Smooth scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }

/* Screen reader only */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.sr-only:focus { position: static; width: auto; height: auto; clip: auto; margin: 0; }

/* ================================================
   Focus Styles (Accessibility)
   ================================================ */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ================================================
   Header
   ================================================ */
#site-header {
  background: rgba(248,250,252,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  transition: background .3s, border-color .3s, box-shadow .3s;
}

[data-theme="dark"] #site-header {
  background: rgba(15,23,42,.85);
}

#site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.logo-link { text-decoration: none; }
.logo-icon { flex-shrink: 0; }

/* ================================================
   Hero / Email Creation Section
   ================================================ */
.hero-section {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.trust-pill {
  animation: fadeInDown .6s ease;
}

/* Creation Card */
.creation-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  transition: border-color .2s;
}

/* Duration Selector */
.duration-btn {
  min-height: 44px;
  transition: all .15s ease;
  position: relative;
}

.duration-btn[aria-pressed="true"] {
  background: rgba(14,165,233,.08) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-primary-dark) !important;
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
  font-weight: 600;
}

[data-theme="dark"] .duration-btn[aria-pressed="true"] {
  color: #38bdf8 !important;
}

.duration-btn:hover:not([aria-pressed="true"]) {
  border-color: #93c5fd;
  background: rgba(14,165,233,.04);
}

/* Create Button */
.create-btn {
  letter-spacing: .01em;
  min-height: 56px;
  position: relative;
  overflow: hidden;
}

.create-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.1);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}

.create-btn:hover::after { transform: scaleX(1); }
.create-btn:active { transform: scale(.99); }

/* ================================================
   Email Display Card
   ================================================ */
.email-card { transition: all .4s ease; }

.email-address-display {
  font-size: clamp(.875rem, 2vw, 1.25rem);
  word-break: break-all;
  letter-spacing: -.02em;
}

/* Countdown */
.countdown-display {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}

/* Action Buttons */
.action-btn {
  min-height: 40px;
  font-size: .8125rem;
  transition: all .15s ease;
  white-space: nowrap;
}

.action-btn:active { transform: scale(.97); }

/* ================================================
   Inbox
   ================================================ */
.inbox-list { max-height: 420px; overflow-y: auto; }

/* Message Row */
.message-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: .75rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--surface-bg);
  transition: all .15s ease;
  position: relative;
}

.message-row:hover {
  background: var(--surface-hover);
  border-color: var(--surface-border);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.message-row.unread::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

html[dir="rtl"] .message-row.unread::before {
  border-radius: 2px 0 0 2px;
  inset-inline-start: auto;
  inset-inline-end: 0;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8125rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.message-sender { font-size: .8125rem; font-weight: 600; }
.message-subject { font-size: .8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-preview { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-time    { font-size: .7rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

/* ================================================
   Skeleton Loaders
   ================================================ */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-pulse .h-3,
.animate-pulse .h-3\.5,
.animate-pulse .h-4,
.animate-pulse .w-9,
[class*="skeleton"] {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: .375rem;
}

[data-theme="dark"] .animate-pulse .h-3,
[data-theme="dark"] .animate-pulse .h-3\.5,
[data-theme="dark"] .animate-pulse .h-4 {
  background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ================================================
   Toast Notifications
   ================================================ */
.toast {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  border-radius: .875rem;
  min-width: 280px;
  max-width: 380px;
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn .3s ease forwards;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.toast.success::before { background: var(--color-success); }
.toast.error::before   { background: var(--color-error); }
.toast.warning::before { background: var(--color-warning); }
.toast.info::before    { background: var(--color-info); }

.toast-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: .1rem; }
.toast.success .toast-icon { color: var(--color-success); }
.toast.error   .toast-icon { color: var(--color-error); }
.toast.warning .toast-icon { color: var(--color-warning); }
.toast.info    .toast-icon { color: var(--color-info); }

.toast-message { font-size: .8125rem; font-weight: 500; color: var(--text-primary); flex: 1; line-height: 1.4; }
.toast-close { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); cursor: pointer; transition: color .15s; }
.toast-close:hover { color: var(--text-primary); }

.toast.removing { animation: toastOut .25s ease forwards; }

@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

html[dir="rtl"] @keyframes toastIn {
  from { transform: translateX(-110%); }
  to   { transform: translateX(0); }
}

@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; max-height: 100px; margin-bottom: .5rem; }
  to   { transform: translateX(110%); opacity: 0; max-height: 0;    margin-bottom: 0; }
}

/* ================================================
   Modal / Dialog
   ================================================ */
.confirm-modal {
  background: var(--surface-card);
  border-radius: 1.25rem;
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { transform: scale(.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);       opacity: 1; }
}

/* ================================================
   Message Reader
   ================================================ */
.message-reader-container {
  animation: modalIn .25s ease;
}

#message-html-frame {
  width: 100%;
  min-height: 300px;
  border: none;
  border-radius: .5rem;
  background: white;
}

/* ================================================
   Features Section
   ================================================ */
.feature-card { transition: all .2s ease; }
.feature-card:hover { transform: translateY(-3px); }

/* ================================================
   How It Works — Steps
   ================================================ */
.steps-container { position: relative; }

/* Connector line on desktop */
@media (min-width: 1024px) {
  .steps-container::before {
    content: '';
    position: absolute;
    top: 24px;
    inset-inline-start: calc(12.5% + 24px);
    width: calc(75% - 48px);
    height: 2px;
    background: linear-gradient(90deg, #38bdf8, #06b6d4);
    opacity: .3;
    z-index: 0;
  }
}

/* ================================================
   Use Cases Swiper
   ================================================ */
.usecases-swiper .swiper-slide { height: auto; }
.usecase-card { height: 100%; }

.usecases-swiper .swiper-pagination-bullet {
  background: #cbd5e1;
  opacity: 1;
}
.usecases-swiper .swiper-pagination-bullet-active {
  background: var(--color-primary);
}

/* ================================================
   FAQ Accordion
   ================================================ */
.faq-item { transition: border-color .2s; }
.faq-item:hover { border-color: #cbd5e1; }
[data-theme="dark"] .faq-item:hover { border-color: #475569; }

.faq-answer { transition: all .3s ease; }
.faq-toggle[aria-expanded="true"] .faq-chevron { transform: rotate(180deg); }

/* ================================================
   Ad Slots
   ================================================ */
.ad-slot {
  text-align: center;
  overflow: hidden;
  border-radius: .75rem;
}

.ad-slot:empty { display: none; }
.ad-container:has(.ad-slot:empty) { display: none; }

/* ================================================
   Sections
   ================================================ */
.features-section, .usecases-section, .faq-section { position: relative; }

/* ================================================
   Trust Pills Row
   ================================================ */
.trust-pill {
  user-select: none;
}

/* ================================================
   CTA Section
   ================================================ */
.cta-section {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  position: relative;
  overflow: hidden;
}

.cta-section::before {
  content: '';
  position: absolute;
  top: -50%;
  inset-inline-end: -10%;
  width: 50%;
  height: 200%;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}

/* ================================================
   Footer
   ================================================ */
.site-footer { position: relative; }

.footer-grid { }

/* ================================================
   Cookie Consent
   ================================================ */
#cookie-banner {
  animation: slideUp .4s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ================================================
   Animations
   ================================================ */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.animate-spin-once { animation: spin .6s ease; }

/* Refresh icon spin on click */
.refresh-icon.spinning { animation: spin .6s linear; }

/* New message highlight */
@keyframes messageHighlight {
  0%   { background: rgba(14,165,233,.15); }
  100% { background: transparent; }
}

.message-row.new-message { animation: messageHighlight 2s ease forwards; }

/* ================================================
   Responsive Breakpoints
   ================================================ */
@media (max-width: 640px) {
  .hero-section { padding-top: 5.5rem; }

  .creation-card { padding: 1.25rem; border-radius: 1.25rem; }

  .duration-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .duration-btn { font-size: .6875rem; padding: .5rem .25rem; min-height: 40px; }

  .action-btn span.hidden { display: none !important; }

  .email-address-display { font-size: .9375rem; }
  .countdown-display { font-size: 1.5rem; }

  .inbox-list { max-height: 340px; }

  .message-row { padding: .75rem; gap: .625rem; }
}

@media (min-width: 768px) {
  .duration-grid { grid-template-columns: repeat(10, 1fr); }
}

/* ================================================
   Dark Mode Overrides
   ================================================ */
[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] .creation-card {
  background: rgba(30,41,59,.9);
}

[data-theme="dark"] .message-row {
  background: rgba(30,41,59,.6);
}

[data-theme="dark"] .message-row:hover {
  background: rgba(51,65,85,.8);
}

[data-theme="dark"] #message-html-frame {
  background: #f8fafc;
}

/* ================================================
   Print Styles
   ================================================ */
@media print {
  #site-header, .site-footer, #toast-container, #cookie-banner,
  .action-btn, .create-btn, .ad-container, .ad-slot,
  #share-modal, #message-reader-modal { display: none !important; }

  body { background: white; color: black; }
  .creation-card, .email-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ================================================
   Reduced Motion
   ================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ================================================
   Lucide Icon Size Helpers
   ================================================ */
[data-lucide] { display: inline-block; vertical-align: middle; }
.w-3.h-3   { width: .75rem;  height: .75rem; }
.w-4.h-4   { width: 1rem;    height: 1rem; }
.w-5.h-5   { width: 1.25rem; height: 1.25rem; }

/* ================================================
   Inline message-unread badge animation
   ================================================ */
@keyframes badgePop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

#unread-badge:not(.hidden) {
  animation: badgePop .3s ease;
}
