@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

html, body {
    overflow-x: hidden;
    width: 100%;
}

body {
    overflow-x: hidden;
    min-width: 320px;
    font-family: 'Inter', sans-serif;
    background-color: #fff;
    color: #0f172a;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img, video, iframe { max-width: 100%; display: block; }
a { text-decoration: none; color: var(--primary); }

/* ─── DESIGN TOKENS ──────────────────────────────────── */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --background: #f8fafc;
    --foreground: #0f172a;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --white: #ffffff;
    --sidebar-width: 240px;
    --nav-height: 60px;
}

/* ─── CONTAINER ──────────────────────────────────────── */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}
@media (min-width: 768px)  { .container { padding: 0 48px; } }
@media (min-width: 1280px) { .container { padding: 0 64px; } }

/* ─── BUTTONS ────────────────────────────────────────── */
.btn { display: inline-block; padding: 10px 20px; border-radius: 9999px; font-weight: 500; text-align: center; cursor: pointer; transition: all 0.2s; border: none; font-size: 14px; }
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-dark); }
.btn-outline { background-color: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background-color: var(--primary); color: white; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-block { display: block; width: 100%; }
.btn-danger { background-color: var(--danger); color: white; }

/* ─── FORMS ──────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 14px; }
.form-control { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px; font-size: 16px; /* min 16px — prevent iOS zoom */ font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); }

/* ─── CARD ───────────────────────────────────────────── */
.card { background-color: var(--card-bg); border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 24px; margin-bottom: 24px; }

/* ─── BADGES ─────────────────────────────────────────── */
.badge { padding: 4px 8px; border-radius: 9999px; font-size: 12px; font-weight: 500; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-primary { background: #e0e7ff; color: #3730a3; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ─── TABLES ─────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { font-weight: 600; color: var(--muted); }

/* ─── MODAL ──────────────────────────────────────────── */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-content { background: white; padding: 30px; border-radius: 20px; width: 90%; max-width: 600px; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-close { position: absolute; top: 20px; right: 20px; font-size: 24px; cursor: pointer; color: var(--muted); }
.proof-item { display: flex; gap: 15px; padding: 15px; border-bottom: 1px solid var(--border); }
.proof-item:last-child { border-bottom: none; }
.proof-img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 1px solid var(--border); flex-shrink: 0; }
.proof-info h4 { margin: 0; font-size: 14px; }
.proof-info p  { font-size: 12px; color: var(--muted); margin: 4px 0; }

/* ─── LANDING ────────────────────────────────────────── */
.landing-body { background-color: white; }
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 15px 48px; background: white; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.brand { font-size: 24px; font-weight: 700; color: var(--text); }
.brand span { color: var(--primary); }
.navbar-links { display: flex; align-items: center; gap: 16px; }
.navbar-hamburger { display: none; background: none; border: none; cursor: pointer; width: 40px; height: 40px; align-items: center; justify-content: center; color: var(--text); }
.navbar-drawer { display: none; }

.hero { padding: 100px 48px; text-align: center; background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%); min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.hero-content h1 { font-size: 48px; font-weight: 700; margin-bottom: 20px; }
.hero-content p  { font-size: 18px; color: var(--muted); margin-bottom: 40px; }
.hero-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }

.features { padding: 80px 48px; text-align: center; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; margin-top: 40px; }
.feature-card { padding: 30px; border-radius: 16px; background: var(--background); }
.feature-icon { font-size: 40px; margin-bottom: 15px; }

/* ─── AUTH PAGES ─────────────────────────────────────── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: #f8fafc;
    padding: 32px 16px 48px;
}
.auth-box {
    background: white;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    padding: 40px 36px;
    width: 100%;
    max-width: 440px;
}
@media (max-width: 480px) {
    .auth-container {
        padding: 20px 12px 40px;
        background: #f8fafc;
    }
    .auth-box {
        padding: 28px 20px;
        border-radius: 16px;
    }
}

/* ─── DASHBOARD LAYOUT ───────────────────────────────── */
.app-container { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: white; border-right: 1px solid var(--border); position: fixed; height: 100vh; overflow-y: auto; padding: 20px 0; z-index: 50; }
.sidebar-brand { padding: 0 20px 20px; font-size: 20px; font-weight: 700; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.sidebar-brand span { color: var(--primary); }
.sidebar-nav { list-style: none; }
.sidebar-nav li a { display: flex; align-items: center; padding: 12px 20px; color: var(--text); font-weight: 500; gap: 10px; transition: all 0.15s; }
.sidebar-nav li a:hover, .sidebar-nav li a.active { background-color: #e0e7ff; color: var(--primary); border-right: 3px solid var(--primary); }
.sidebar-nav li a.admin-link { color: #dc2626; }
.sidebar-nav li a.admin-link:hover { background-color: #fee2e2; border-right-color: #dc2626; }
.main-content { flex: 1; margin-left: var(--sidebar-width); padding: 30px 40px; }

/* ─── STATS GRID ─────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 30px;
}
.stats-grid .card {
    padding: 20px;
    margin-bottom: 0;
}
.stats-grid .card:last-child {
    grid-column: 1 / -1;
}
.stats-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stats-number { font-size: 28px; font-weight: 700; color: #0f172a; }
.stats-number.success { color: var(--success); }

/* ─── SETTINGS ───────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 1024px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.theme-card { border: 2px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; text-align: center; }
.theme-card.active { border-color: var(--primary); background: #e0e7ff; }
.theme-preview { height: 60px; border-radius: 8px; margin-bottom: 10px; background: #ddd; }
.theme-arctic  .theme-preview { background: white; border: 1px solid #ccc; }
.theme-midnight .theme-preview { background: #0f172a; }
.theme-coral   .theme-preview { background: white; border: 2px solid #ef4444; }
.theme-ocean   .theme-preview { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.theme-forest  .theme-preview { background: #064e3b; border: 2px solid #fbbf24; }

/* ─── GENERATE PAGE ──────────────────────────────────── */
.generate-page {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 24px 16px;
    box-sizing: border-box;
}
.generate-page h1 {
    font-size: 24px;
    word-break: break-word;
    margin-bottom: 24px;
}
@media (min-width: 1024px) {
    .generate-page h1 { font-size: 32px; }
}
.generate-page .card {
    width: 100%;
    max-width: 480px;
    margin: 0 auto 24px;
}
.generate-page .form-control {
    width: 100%;
    font-size: 16px;
}
.generate-page .btn-generate {
    width: 100%;
    height: 52px;
    font-size: 16px;
}

/* ─── SETTINGS UPLOAD ZONE ─────────────────────────── */
#upload-zone {
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  background: #f8fafc;
}

#upload-zone:hover {
  border-color: #6366f1;
  background: #f8faff;
}

#upload-zone.has-file {
  border: 2px solid #6366f1;
  background: #eff6ff;
  padding: 12px 16px;
  text-align: left;
}

#zone-empty p:first-of-type {
  font-size: 14px;
  color: #64748b;
  margin-top: 8px;
}

#zone-empty p:last-of-type {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

#zone-filled {
  display: flex;
  align-items: center;
  gap: 12px;
}

#upload-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.05);
}

#file-name {
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

#scan-status {
  font-size: 12px;
  margin-top: 2px;
  font-weight: 500;
}

#scan-status.scanning { color: #f59e0b; }
#scan-status.success  { color: #10b981; }
#scan-status.error    { color: #dc2626; }

.api-key-row { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.api-key-input { 
    flex: 1; 
    background: #f8fafc; 
    border: 1px solid #e2e8f0; 
    border-radius: 8px; 
    padding: 10px 14px; 
    font-family: monospace; 
    font-size: 13px; 
    color: #0f172a; 
}
.api-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.api-btn:hover { background: #f8fafc; }
.api-btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.api-btn-primary:hover { background: var(--primary-dark); }

.danger-zone {
    margin-top: 24px;
    border-top: 1px solid #fee2e2;
    padding-top: 20px;
}
.btn-regenerate {
    background: white;
    border: 1px solid #fca5a5;
    color: #dc2626;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.btn-regenerate:hover { background: #fff1f2; }

/* ─── PUBLIC QR PAGE ─────────────────────────────────── */
.public-qr-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; background: var(--background); }
.public-qr-box { background: white; padding: 30px 24px; border-radius: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); width: 100%; max-width: 400px; text-align: center; }
.public-qr-box img { width: 100%; max-width: 280px; margin: 24px auto; border-radius: 16px; padding: 16px; background: white; box-shadow: 0 4px 24px rgba(0,0,0,0.1); }
.qr-theme-arctic   { background: white; border: 1px solid #e2e8f0; color: #0f172a; }
.qr-theme-midnight { background: #0f172a; color: white; }
.qr-theme-coral    { background: white; border: 4px solid #ef4444; color: #0f172a; }
.qr-theme-ocean    { background: linear-gradient(135deg, #1e3a8a, #3b82f6); color: white; }
.qr-theme-forest   { background: #064e3b; border: 4px solid #fbbf24; color: white; }

/* ─── API DOCS LEGACY ─────────────────────────────────── */
.docs-container { max-width: 800px; margin: 0 auto; padding: 40px 20px; }
.docs-block { background: #1e293b; color: #f8fafc; padding: 16px; border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0; font-family: monospace; font-size: 13px; position: relative; }
.method-badge  { font-weight: bold; padding: 2px 6px; border-radius: 4px; font-size: 12px; margin-right: 10px; }
.method-get    { background: #10b981; color: white; }
.method-post   { background: #3b82f6; color: white; }
.method-delete { background: #ef4444; color: white; }

/* ─── BOTTOM NAV (mobile only) ───────────────────────── */
.bottom-nav { display: none; }

/* ─── MOBILE TABLE CARD STYLE ────────────────────────── */
.mobile-card-row { display: none; }

/* =====================================================
   TABLET — 768px–1024px
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar { width: 60px; }
    .sidebar-brand { font-size: 0; padding: 10px; text-align: center; }
    .sidebar-brand::first-letter { font-size: 24px; }
    .sidebar-nav li a { padding: 15px; justify-content: center; }
    .sidebar-nav li a span:last-child { display: none; }
    .main-content { margin-left: 60px; padding: 20px; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================
   MOBILE — max 768px
   ===================================================== */
@media (max-width: 768px) {

    /* --- Navbar --- */
    .navbar { padding: 0 16px; height: 56px; }
    .navbar-links { display: none; }
    .navbar-hamburger { display: flex; }

    .navbar-drawer {
        display: block;
        position: fixed;
        top: 56px; left: 0; right: 0;
        background: white;
        border-bottom: 1px solid var(--border);
        padding: 12px;
        z-index: 200;
        transform: translateY(-120%);
        transition: transform 0.25s ease;
        box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    }
    .navbar-drawer.open { transform: translateY(0); }
    .navbar-drawer a {
        display: block;
        padding: 12px 16px;
        border-radius: 8px;
        font-size: 15px;
        color: var(--text);
        font-weight: 500;
        transition: background 0.15s;
    }
    .navbar-drawer a:hover { background: var(--background); }
    .navbar-drawer .drawer-btn { display: block; width: 100%; margin-top: 8px; text-align: center; }

    /* --- Hero --- */
    .hero { padding: 80px 24px 48px; min-height: auto; }
    .hero-content h1 { font-size: 28px; }
    .hero-content p  { font-size: 16px; }
    .hero-actions { flex-direction: column; gap: 12px; }
    .hero-actions .btn { width: 100%; }

    /* --- Features --- */
    .features { padding: 48px 16px; }
    .feature-grid { grid-template-columns: 1fr; }
    .feature-card { padding: 24px; }


    /* --- Dashboard layout --- */
    .app-container { flex-direction: column; padding-bottom: 80px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px 16px; }

    /* --- Stats cards --- */
    .stats-grid-3 { grid-template-columns: 1fr 1fr !important; }

    /* --- Table → card rows --- */
    table thead { display: none; }
    table tbody tr {
        display: block;
        background: white;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }
    table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #f1f5f9;
        padding: 8px 0;
        font-size: 14px;
    }
    table tbody tr td:last-child { border-bottom: none; padding-bottom: 0; }
    table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        margin-right: 12px;
    }

    /* --- Bottom nav --- */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: white;
        border-top: 1px solid var(--border);
        z-index: 100;
        justify-content: space-around;
        align-items: center;
        height: 64px;
        padding: 0 8px;
    }
    .bottom-nav a {
        color: var(--muted);
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 10px;
        gap: 3px;
        flex: 1;
        padding: 8px 4px;
        border-radius: 8px;
    }
    .bottom-nav a.active svg { stroke: var(--primary); }
    .bottom-nav a.admin-link { color: #dc2626; }
    .bottom-nav svg { width: 22px; height: 22px; stroke-width: 1.75; fill: none; }
    .bottom-nav span { font-size: 10px; font-weight: 500; margin-top: 4px; }

    /* --- Settings --- */
    .settings-grid { grid-template-columns: 1fr; }

    /* --- Modal full screen on mobile --- */
    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        top: 0;
        position: fixed;
    }

    /* --- Code blocks --- */
    .docs-block, pre, code {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 12px;
        white-space: pre;
    }

    /* --- Footer --- */
    .footer { padding: 40px 16px 24px; }
}

@media (max-width: 380px) {
    .hero-content h1 { font-size: 24px; }
    .bottom-nav a span:last-child { display: none; }
}
