/* ═══════════════════════════════════════════════════════════════════════════
   Elder Paisios Scanner — Design System
   Calm, respectful, mobile-first aesthetic for religious/cultural content
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
    /* ─ Brand palette: #36241c · #000 · #fff ─ */
    --color-espresso:    #36241c;   /* primary brand — dark espresso brown */
    --color-espresso-dk: #241811;   /* darkened hover state */
    --color-espresso-lt: #5C3D30;   /* lighter espresso for gradients */
    --color-black:       #000000;
    --color-white:       #ffffff;

    /* ─ Surfaces (warm white tones derived from espresso) ─ */
    --color-bg:          #FBF9F7;   /* warm off-white background */
    --color-surface:     #FFFFFF;
    --color-surface-2:   #F2EDE8;   /* warm pale — secondary surfaces */
    --color-surface-3:   #E8DDD6;   /* warm pale — borders, dividers */

    /* ─ Semantic ─ */
    --color-primary:     #36241c;
    --color-primary-dk:  #241811;
    --color-accent:      #36241c;   /* same brand colour for accent */
    --color-accent-lt:   #C4A99A;   /* warm light tint for dark backgrounds */
    --color-success:     #2D5A27;
    --color-danger:      #7A1F1F;

    /* ─ Text ─ */
    --color-text:        #000000;
    --color-text-inv:    #FFFFFF;
    --color-text-muted:  #6B5A52;   /* warm brown-grey */
    --color-border:      #D6CCC6;

    --radius-sm:   8px;
    --radius-md:   14px;
    --radius-lg:   20px;
    --radius-full: 999px;

    --shadow-sm:  0 1px 3px rgba(54,36,28,0.08);
    --shadow-md:  0 4px 16px rgba(54,36,28,0.12);
    --shadow-lg:  0 12px 40px rgba(54,36,28,0.18);

    --transition: all 0.22s cubic-bezier(.4,0,.2,1);

    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-base: 16px;
    --line-height: 1.65;

    color-scheme: light;
}

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

html { font-size: var(--font-size-base); -webkit-text-size-adjust: 100%; }

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

main { flex: 1; }

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

img { max-width: 100%; height: auto; display: block; }

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--color-primary);
}
h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.4rem, 4vw, 2rem); }
h3 { font-size: clamp(1.1rem, 3vw, 1.4rem); }
p  { margin-bottom: 1rem; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
    background: #000;
    border-bottom: 2px solid var(--color-espresso);
    padding: 1.1rem 1.5rem;
    padding-top: calc(env(safe-area-inset-top, 0px) + 1.1rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 0.75rem;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #fff;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
    flex-shrink: 0;
}
.navbar-brand:hover { color: var(--color-accent-lt); }

/* Hide brand text on mobile — keep only the ✦ icon */
.navbar-brand-text { display: inline; }
@media (max-width: 540px) {
    .navbar-brand-text { display: none; }
}

.navbar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--color-espresso);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    color: #fff;   /* force white so ✦ doesn't render black */
}

.navbar-actions { display: flex; gap: 0.25rem; align-items: center; }

.nav-link-pill {
    color: rgba(255,255,255,0.85);
    font-size: 1.2rem;          /* bigger emoji */
    font-weight: 500;
    padding: 0.55rem 0.7rem;   /* larger tap area */
    border-radius: var(--radius-full);
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1;
    min-width: 44px;            /* iOS minimum tap target */
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}
.nav-link-pill:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* On small screens: hide text labels, keep only the emoji */
.nav-label { display: inline; }
@media (max-width: 540px) {
    .nav-label { display: none; }
}

/* ── Containers ───────────────────────────────────────────────────────────── */
.container    { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 640px;  margin: 0 auto; padding: 0 1.5rem; }
.container-md { max-width: 800px;  margin: 0 auto; padding: 0 1.5rem; }

/* ── Main content area ────────────────────────────────────────────────────── */
main { padding-top: 1.5rem; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card-body { padding: 1.75rem; }
.card-body-lg { padding: 2.25rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.875rem 2rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn-primary {
    background: var(--color-espresso);
    color: #fff;
    box-shadow: 0 4px 14px rgba(54,36,28,0.30);
}
.btn-primary:hover {
    background: var(--color-black);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.35);
}
.btn-primary:active { transform: translateY(0); }

.btn-accent {
    background: var(--color-black);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.30);
}
.btn-accent:hover {
    background: var(--color-espresso);
    color: #fff;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--color-espresso);
    border: 2px solid var(--color-espresso);
}
.btn-outline:hover {
    background: var(--color-espresso);
    color: #fff;
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    padding: 0.75rem 1.5rem;
}
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #6b1414; color: #fff; }

/* Vibrant green button for external (non-YouTube) links */
.btn-external {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    box-shadow: 0 4px 18px rgba(22, 163, 74, 0.40);
}
.btn-external:hover {
    background: linear-gradient(135deg, #15803d 0%, #166534 100%);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(22, 163, 74, 0.55);
}
.btn-external:active { transform: translateY(0); }

.btn-sm { font-size: 0.85rem; padding: 0.5rem 1.1rem; }
.btn-lg { font-size: 1.15rem; padding: 1.1rem 2.5rem; }
.btn-full { width: 100%; }

.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-surface);
    transition: var(--transition);
    outline: none;
}
.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.12);
}
.form-control.is-invalid { border-color: var(--color-danger); }

.form-text { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.3rem; }

.field-validation-error { color: var(--color-danger); font-size: 0.85rem; margin-top: 0.3rem; display: block; }

.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check-input { width: 18px; height: 18px; accent-color: var(--color-primary); cursor: pointer; }
.form-check-label { font-size: 0.95rem; cursor: pointer; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6B6B' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 1rem center; padding-right: 2.5rem; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
}
.alert-success { background: #E8F5E9; color: var(--color-success); border-left: 4px solid var(--color-success); }
.alert-danger  { background: #FDEAEA; color: var(--color-danger);  border-left: 4px solid var(--color-danger);  }
.alert-info    { background: #E3EEF8; color: var(--color-primary); border-left: 4px solid var(--color-primary); }

/* ── Hero Section ─────────────────────────────────────────────────────────── */
.hero {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1.25rem;
    background: linear-gradient(160deg, var(--color-bg) 0%, var(--color-surface-2) 100%);
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius-full);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.hero-icon {
    font-size: 4rem;
    margin-bottom: 1.25rem;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(26,58,92,0.15));
}

.hero-title { margin-bottom: 1rem; color: var(--color-primary); }

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    max-width: 520px;
    margin: 0 auto 2.5rem;
    font-weight: 400;
}

.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* ── Scanner Page ─────────────────────────────────────────────────────────── */
.scanner-page {
    background: #000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: #fff;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.scanner-header-title { font-size: 1rem; font-weight: 600; }

#camera-video {
    width: 100%;
    height: 100vh;
    object-fit: cover;
    display: block;
}

.scanner-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: min(75vw, 340px);
    height: min(75vw, 340px);
    border: 3px solid rgba(255,255,255,0.9);
    border-radius: var(--radius-lg);
    position: relative;
    box-shadow: 0 0 0 4000px rgba(0,0,0,0.45);
}

/* Corner decorations */
.scan-frame::before, .scan-frame::after,
.scan-frame-inner::before, .scan-frame-inner::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-color: var(--color-espresso-lt);
    border-style: solid;
}
.scan-frame::before  { top: -3px;  left: -3px;  border-width: 4px 0 0 4px; border-radius: 4px 0 0 0; }
.scan-frame::after   { top: -3px;  right: -3px; border-width: 4px 4px 0 0; border-radius: 0 4px 0 0; }
.scan-frame-inner::before { bottom: -3px; left: -3px;  border-width: 0 0 4px 4px; border-radius: 0 0 0 4px; }
.scan-frame-inner::after  { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 4px 0; }

/* Scanning line animation */
@keyframes scanLine {
    0%   { top: 8%; opacity: 1; }
    95%  { top: 88%; opacity: 1; }
    100% { top: 8%; opacity: 0; }
}

.scan-line {
    position: absolute;
    left: 6px;
    right: 6px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-espresso-lt), transparent);
    top: 8%;
    animation: scanLine 2.5s ease-in-out infinite;
    border-radius: 2px;
}

.scanner-hint {
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 1.5rem;
    padding: 0 1rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.scanner-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.btn-capture {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid rgba(255,255,255,0.4);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}
.btn-capture:hover { transform: scale(1.08); }
.btn-capture:active { transform: scale(0.95); }
.btn-capture.scanning { background: var(--color-accent); }

/* ── Result Page ──────────────────────────────────────────────────────────── */
.result-hero {
    padding: 3rem 1.25rem 2rem;
    text-align: center;
    background: linear-gradient(160deg, #E8F0F8 0%, var(--color-bg) 100%);
}

.result-icon { font-size: 3.5rem; display: block; margin-bottom: 1rem; }

.result-card {
    border: 1px solid var(--color-border);
    border-top: 4px solid var(--color-espresso);
}

.result-thumbnail {
    width: 100%;
    max-height: 420px;
    object-fit: contain;
    background: var(--color-surface-2);
}

.page-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    margin-bottom: 0.75rem;
}

/* ── Search Page ──────────────────────────────────────────────────────────── */
.search-box {
    position: relative;
}
.search-box .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}
.search-box .form-control { padding-left: 2.75rem; }

.search-result-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--color-text);
    border: 1px solid transparent;
}
.search-result-item:hover {
    background: var(--color-surface);
    border-color: var(--color-border);
    transform: translateX(4px);
    color: var(--color-text);
}
.search-result-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--color-surface-2);
    flex-shrink: 0;
}
.search-result-thumb-placeholder {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.4rem;
}

/* ── Admin ────────────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--color-black);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.admin-sidebar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 0 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--color-espresso);
    margin-bottom: 0.75rem;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 1.25rem;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    border-radius: 0;
}
.admin-nav-item:hover, .admin-nav-item.active {
    background: var(--color-espresso);
    color: #fff;
}
.admin-nav-item .nav-icon { font-size: 1.05rem; }

.admin-main {
    flex: 1;
    padding: 2rem;
    min-width: 0;
    background: var(--color-bg);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}
.stat-card-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); line-height: 1; }
.stat-card-label { font-size: 0.82rem; color: var(--color-text-muted); margin-top: 0.3rem; font-weight: 500; }
.stat-card-icon { font-size: 2rem; opacity: 0.15; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }

table { width: 100%; border-collapse: collapse; background: var(--color-surface); }
thead { background: var(--color-espresso); color: #fff; }
thead th { padding: 0.85rem 1rem; font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--color-border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-2); }
tbody td { padding: 0.85rem 1rem; font-size: 0.9rem; vertical-align: middle; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
}
.badge-success { background: #E8F5E9; color: var(--color-success); }
.badge-danger  { background: #FDEAEA; color: var(--color-danger);  }
.badge-primary { background: #E3EEF8; color: var(--color-primary); }
.badge-muted   { background: var(--color-surface-2); color: var(--color-text-muted); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.section { padding: 3rem 1.25rem; }
.section-sm { padding: 1.75rem 1.25rem; }
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    width: 24px; height: 24px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    display: inline-block;
}

/* Pulse animation for scanning state */
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    background: var(--color-black);
    color: rgba(255,255,255,0.65);
    text-align: center;
    padding: 1.25rem;
    font-size: 0.8rem;
}
.footer a { color: rgba(255,255,255,0.75); }
.footer a:hover { color: var(--color-accent-lt); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; height: auto; position: static; padding: 0.75rem 0; }
    .admin-sidebar-brand { padding-bottom: 0.75rem; }
    .admin-nav-item { display: inline-flex; padding: 0.5rem 0.85rem; }
    .admin-main { padding: 1.25rem; }
    .hero { min-height: auto; padding: 3rem 1.25rem; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .hero-actions .btn { text-align: center; }
}