/* BuildCode App Shell Styles */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --navy: #0f2942;
    --navy-light: #1a3d5c;
    --blue: #2563eb;
    --blue-light: #3b82f6;
    --orange: #f97316;
    --orange-dark: #ea580c;
    --orange-light: #fff7ed;
    --slate: #475569;
    --slate-light: #94a3b8;
    --bg: #f8fafc;
    --white: #ffffff;
    --green: #22c55e;
    --red: #ef4444;
    --border: rgba(15,41,66,0.08);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--navy);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== APP HEADER ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 56px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}
.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--navy);
    text-decoration: none;
}
.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--orange);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 800;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-badge {
    width: 36px;
    height: 36px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slate);
    cursor: pointer;
    transition: all 0.2s;
}
.user-badge:hover { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(64px + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--slate-light);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { color: var(--slate); }
.nav-item.active {
    color: var(--orange);
}
.nav-item.active svg { stroke: var(--orange); }

/* ===== MAIN CONTENT ===== */
.app-main {
    margin-top: 56px;
    margin-bottom: calc(64px + var(--safe-bottom));
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== PAGES ===== */
.page {
    padding: 24px 16px;
    max-width: 640px;
    margin: 0 auto;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.page-header {
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}
.page-desc {
    color: var(--slate);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ===== SEARCH ===== */
.search-container {
    margin-bottom: 24px;
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.search-box:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.search-icon {
    position: absolute;
    left: 14px;
    color: var(--slate-light);
    pointer-events: none;
}
.search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 14px 14px 44px;
    font-size: 1rem;
    font-family: inherit;
    background: transparent;
    color: var(--navy);
}
.search-box input::placeholder { color: var(--slate-light); }
.voice-btn {
    background: none;
    border: none;
    padding: 14px;
    color: var(--slate-light);
    cursor: pointer;
    transition: color 0.2s;
}
.voice-btn:hover { color: var(--orange); }
.voice-btn.listening { color: var(--red); animation: pulse 1.5s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== CATEGORIES ===== */
.quick-categories {
    margin-bottom: 24px;
}
.quick-categories h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--slate-light);
    margin-bottom: 12px;
}
.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.category-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--navy);
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.category-chip:hover { border-color: var(--orange); background: var(--orange-light); }
.chip-icon { font-size: 1rem; }

/* ===== SEARCH RESULTS ===== */
.search-results {
    display: none;
}
.search-results.has-results {
    display: block;
}
.result-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}
.result-card:hover { box-shadow: var(--shadow-md); }
.result-code {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}
.result-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
}
.result-excerpt {
    color: var(--slate);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ===== GUIDE EMPTY STATE ===== */
.guide-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--slate);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}
.guide-empty h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--navy);
}
.guide-empty p {
    font-size: 0.9rem;
    color: var(--slate-light);
}

/* ===== AUDITOR ===== */
.auditor-promo {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}
.promo-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-align: center;
}
.promo-icon {
    margin-bottom: 16px;
}
.promo-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.promo-card p {
    color: var(--slate);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}
.btn-audit {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--orange);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-audit:hover { background: var(--orange-dark); }
.btn-audit-secondary {
    background: var(--blue);
}
.btn-audit-secondary:hover { background: #1d4ed8; }
.auditor-banner {
    background: var(--orange-light);
    border: 1px solid rgba(249,115,22,0.15);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--navy);
}
.auditor-banner strong { color: var(--orange-dark); }

/* ===== SETTINGS ===== */
.settings-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.settings-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.settings-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.settings-note {
    color: var(--slate-light);
    font-size: 0.8rem;
    margin-bottom: 16px;
}
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.setting-row strong {
    font-size: 0.9rem;
    display: block;
    margin-bottom: 2px;
}
.setting-desc {
    color: var(--slate);
    font-size: 0.8rem;
}
.btn-setting {
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--navy);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-setting:hover { border-color: var(--blue); color: var(--blue); }
.btn-setting-disabled { opacity: 0.5; cursor: not-allowed; }
.btn-setting-disabled:hover { border-color: var(--border); color: var(--navy); }
.btn-upgrade {
    background: var(--orange);
    color: white;
    border-color: var(--orange);
}
.btn-upgrade:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: white; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(15,41,66,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open {
    display: flex;
}
.modal {
    background: var(--white);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 420px;
    position: relative;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--slate-light);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--navy); }
.modal h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.modal-desc {
    color: var(--slate);
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--blue); }
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--orange);
    color: white;
    padding: 14px 32px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1rem;
    font-family: inherit;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-full { width: 100%; }
.modal-footer-text {
    text-align: center;
    color: var(--slate-light);
    font-size: 0.8rem;
    margin-top: 16px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: calc(80px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--navy);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 300;
    transition: transform 0.3s ease;
    white-space: nowrap;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .app-main { margin-bottom: 0; }
    .bottom-nav {
        top: 0;
        bottom: auto;
        left: 0;
        width: 220px;
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        padding-top: 72px;
        gap: 4px;
        padding-bottom: 0;
        border-top: none;
        border-right: 1px solid var(--border);
    }
    .nav-item {
        flex-direction: row;
        width: 100%;
        padding: 12px 20px;
        border-radius: 0 8px 8px 0;
        font-size: 0.9rem;
        justify-content: flex-start;
        gap: 12px;
    }
    .app-main {
        margin-left: 220px;
    }
    .page {
        padding: 32px 24px;
    }
    .auditor-promo {
        grid-template-columns: 1fr 1fr;
    }
}
