/* =============================================================
   ImageRunner — Dark Theme CSS
   Palette:
     bg:      #1a1a2e  (page background)
     bg2:     #16213e  (cards, sidebar)
     accent:  #0f3460  (inputs, table header tint)
     primary: #e94560  (CTA, active states)
   ============================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:            #1a1a2e;
    --bg2:           #16213e;
    --accent:        #0f3460;
    --primary:       #e94560;
    --primary-hover: #c73652;
    --text:          #e0e0f0;
    --text-muted:    #8888aa;
    --border:        #2a2a4a;
    --success:       #2ecc71;
    --warning:       #f39c12;
    --danger:        #e74c3c;
    --radius:        8px;
    --radius-lg:     14px;
    --shadow:        0 4px 24px rgba(0, 0, 0, 0.4);
    --sidebar-w:     224px;
    --nav-h:         60px;
    --font:          'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    --font-mono:     'Consolas', 'Courier New', monospace;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Container ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* =============================================================
   Navbar
   ============================================================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--nav-h);
    background: rgba(22, 33, 62, 0.95);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.navbar-brand { display: flex; align-items: center; }

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.3px;
}
.brand-link:hover { color: var(--primary); }

.brand-icon { color: var(--primary); font-size: 18px; }
.brand-name { letter-spacing: 0.5px; }

.navbar-links {
    display: flex;
    align-items: center;
    gap: 28px;
}
.navbar-links a {
    color: var(--text-muted);
    font-size: 14px;
    transition: color 0.2s;
}
.navbar-links a:hover { color: var(--text); }

/* =============================================================
   Buttons
   ============================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    transition: background 0.15s, opacity 0.15s, transform 0.1s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
    user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; color: #fff; }

.btn-sm  { padding: 4px 12px; font-size: 12px; }
.btn-lg  { padding: 13px 36px; font-size: 16px; }
.btn-block { width: 100%; }

/* =============================================================
   Badges
   ============================================================= */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    vertical-align: middle;
}
.badge-primary { background: var(--primary);                          color: #fff; }
.badge-success { background: rgba(46,204,113,0.18); color: var(--success); border: 1px solid rgba(46,204,113,0.35); }
.badge-warning { background: rgba(243,156,18,0.18); color: var(--warning); border: 1px solid rgba(243,156,18,0.35); }
.badge-muted   { background: rgba(136,136,170,0.13); color: var(--text-muted); border: 1px solid var(--border); }
.badge-danger  { background: rgba(231,76,60,0.18);  color: var(--danger);  border: 1px solid rgba(231,76,60,0.35); }

/* =============================================================
   Cards
   ============================================================= */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(15, 52, 96, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 600; margin: 0; }

.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* =============================================================
   Tables
   ============================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: rgba(15, 52, 96, 0.3);
    white-space: nowrap;
}
.table td {
    padding: 11px 16px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(15, 52, 96, 0.18); }

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* =============================================================
   Forms
   ============================================================= */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.15);
}
.form-control::placeholder { color: var(--text-muted); opacity: 1; }

textarea.form-control { resize: vertical; min-height: 100px; line-height: 1.6; }

input[type="file"].form-control {
    cursor: pointer;
    padding: 8px 12px;
}
input[type="file"].form-control::-webkit-file-upload-button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    margin-right: 12px;
    font-family: var(--font);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* =============================================================
   Alerts
   ============================================================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}
.alert-error   { background: rgba(231,76,60,0.14);  border: 1px solid rgba(231,76,60,0.3);  color: #ff8a7a; }
.alert-success { background: rgba(46,204,113,0.12); border: 1px solid rgba(46,204,113,0.3); color: #5ddc90; }

/* =============================================================
   Utilities
   ============================================================= */
.text-muted  { color: var(--text-muted); }
.text-mono   { font-family: var(--font-mono); font-size: 13px; }
.mt-2        { margin-top: 8px; }
.mt-4        { margin-top: 24px; }
.mb-4        { margin-bottom: 24px; }
.hidden      { display: none !important; }

code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(15, 52, 96, 0.5);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
}

pre {
    font-family: var(--font-mono);
}

/* Empty state */
.empty-state {
    padding: 52px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.8;
}

/* =============================================================
   Footer
   ============================================================= */
.footer {
    margin-top: auto;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* =============================================================
   Landing — Hero
   ============================================================= */
.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 64px;
    min-height: calc(100vh - var(--nav-h));
    padding: 80px 48px;
    max-width: 1100px;
    margin: 0 auto;
}

.hero-content { flex: 1; max-width: 580px; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid rgba(233, 69, 96, 0.28);
    border-radius: 20px;
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 24px;
    letter-spacing: 0.5px;
}

.hero-title {
    font-size: 80px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -3px;
    background: linear-gradient(135deg, #ffffff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
}

.hero-subtitle {
    font-size: 22px;
    color: var(--text);
    margin-bottom: 14px;
    font-weight: 500;
}

.hero-desc {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 40px;
    line-height: 1.8;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.version-badge {
    font-size: 13px;
    color: var(--text-muted);
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-family: var(--font-mono);
}

.download-status {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
}
.download-status.success { background: rgba(46,204,113,0.12); color: var(--success); }
.download-status.error   { background: rgba(231,76,60,0.12);  color: #ff8a7a; }

/* Phone mockup */
.hero-visual { flex: 0 0 auto; }

.phone-mockup {
    width: 200px;
    height: 390px;
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: 36px;
    padding: 48px 22px 28px;
    box-shadow: var(--shadow), 0 0 80px rgba(233, 69, 96, 0.08);
    position: relative;
    overflow: hidden;
}
.phone-mockup::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 7px;
    background: var(--border);
    border-radius: 4px;
}
.phone-mockup::after {
    content: '';
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
}

.phone-screen { display: flex; flex-direction: column; gap: 10px; height: 100%; }

.screen-line {
    height: 8px;
    background: linear-gradient(90deg, var(--accent) 60%, transparent 100%);
    border-radius: 4px;
    animation: line-pulse 2s ease-in-out infinite alternate;
}
.screen-line.short { width: 65%; }

.screen-match-box {
    height: 80px;
    background: rgba(233, 69, 96, 0.12);
    border: 2px solid rgba(233, 69, 96, 0.45);
    border-radius: var(--radius);
    margin: 6px 0;
    position: relative;
    animation: match-glow 1.6s ease-in-out infinite alternate;
}
.screen-match-box::before,
.screen-match-box::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border-color: var(--primary);
    border-style: solid;
}
.screen-match-box::before { top: -2px; left: -2px; border-width: 2px 0 0 2px; }
.screen-match-box::after  { bottom: -2px; right: -2px; border-width: 0 2px 2px 0; }

@keyframes line-pulse { from { opacity: 0.4; } to { opacity: 0.9; } }
@keyframes match-glow {
    from { box-shadow: 0 0 0  rgba(233,69,96,0); }
    to   { box-shadow: 0 0 20px rgba(233,69,96,0.35); }
}

/* =============================================================
   Landing — Sections
   ============================================================= */
.section      { padding: 88px 0; }
.section-dark { background: rgba(15, 52, 96, 0.15); }

.section-title {
    font-size: 38px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 52px;
    letter-spacing: -0.5px;
}

/* Features grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 20px;
}

.feature-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover {
    border-color: rgba(233, 69, 96, 0.5);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.feature-icon { font-size: 34px; margin-bottom: 14px; }
.feature-card h3 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.feature-card p  { color: var(--text-muted); font-size: 14px; line-height: 1.75; }

/* Changelog */
.changelog-list { display: flex; flex-direction: column; gap: 20px; }

.changelog-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.changelog-header {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 52, 96, 0.3);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.changelog-version { font-size: 18px; font-weight: 700; color: var(--primary); }
.changelog-date    { color: var(--text-muted); font-size: 13px; margin-left: auto; }

.changelog-body { padding: 16px 20px; }
.changelog-text {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.75;
}

/* =============================================================
   Admin Layout
   ============================================================= */
.admin-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--nav-h));
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-header .brand-icon { font-size: 22px; color: var(--primary); margin-bottom: 2px; }
.sidebar-header > span:nth-child(2) { font-weight: 700; font-size: 15px; }
.sidebar-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav {
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}
.sidebar-link:hover  { background: rgba(15,52,96,0.5); color: var(--text); }
.sidebar-link.active { background: rgba(233,69,96,0.14); color: var(--primary); font-weight: 600; }
.sidebar-link.active:hover { color: var(--primary); }

.sidebar-icon   { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; }
.sidebar-divider { height: 1px; background: var(--border); margin: 8px 4px; }
.sidebar-logout { color: var(--danger) !important; }
.sidebar-logout:hover { background: rgba(231,76,60,0.1) !important; }

/* Admin main content area */
.admin-main    { flex: 1; overflow: auto; }
.admin-content { padding: 32px; }

/* Page header */
.page-header {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: rgba(233,69,96,0.4); transform: translateY(-2px); }

.stat-icon  { font-size: 30px; flex-shrink: 0; }
.stat-value { font-size: 38px; font-weight: 800; line-height: 1; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }

/* Upload form */
.upload-form { max-width: 680px; }

/* Templates grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    padding: 20px;
}

.template-card {
    background: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, transform 0.15s;
}
.template-card:hover { border-color: var(--primary); transform: translateY(-2px); }

.template-preview {
    height: 100px;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.template-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.template-no-preview  { font-size: 30px; color: var(--text-muted); display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }

.template-info { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.template-name {
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-meta { font-size: 11px; color: var(--text-muted); }

/* =============================================================
   Login page
   ============================================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.brand-icon-lg { font-size: 44px; color: var(--primary); display: block; margin-bottom: 10px; }
.login-logo h2 { font-size: 20px; font-weight: 700; }

.login-back { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* =============================================================
   Responsive
   ============================================================= */
.nav-icon { display: none; }
.nav-logout { margin-left: -16px; }

/* Hamburger button */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius);
    transition: background 0.2s;
}
.nav-toggle:hover { background: rgba(255,255,255,0.06); }
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 900px) {
    .hero { flex-direction: column; padding: 60px 24px; text-align: center; gap: 48px; }
    .hero-title { font-size: 56px; letter-spacing: -2px; }
    .hero-visual { display: none; }
    .hero-actions { justify-content: center; }
}

@media (max-width: 768px) {
    .navbar { padding: 0 16px; }
    .nav-toggle { display: flex; }

    .navbar-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        flex-direction: column;
        background: rgba(22, 33, 62, 0.98);
        border-bottom: 1px solid var(--border);
        padding: 8px 16px 16px;
        gap: 2px;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 190;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    }
    .navbar-links.open { display: flex; }
    .navbar-links a,
    .navbar-links button {
        display: flex !important;
        width: 100%;
        padding: 10px 12px;
        border-radius: var(--radius);
        font-size: 15px;
        margin: 0;
        box-sizing: border-box;
    }
    .navbar-links .btn { justify-content: center; margin-top: 4px; }
    .navbar-links a:not(.btn):hover { background: rgba(255,255,255,0.05); color: var(--text); }
    .nav-email { display: none; }
    .nav-icon { display: inline; }

    .admin-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: var(--nav-h);
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border);
        z-index: 100;
    }
    .sidebar-header { display: none; }
    .sidebar-nav { flex-direction: row; padding: 6px 8px; overflow-x: auto; }
    .sidebar-link { padding: 8px 12px; font-size: 13px; white-space: nowrap; gap: 6px; }
    .sidebar-divider { display: none; }
    .admin-content { padding: 16px; }
    .page-header h1 { font-size: 22px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .hero-title { font-size: 42px; }
    .section-title { font-size: 28px; }
    .features-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 20px; }
    .templates-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
