/* ============================================
   Corpira — AI-Powered Corporate Access
   Sidebar app layout — dark theme
   ============================================ */

:root {
    --bg-primary:    #0B1120;
    --bg-secondary:  #111827;
    --bg-card:       #1A2332;
    --bg-input:      #1E293B;
    --sidebar-bg:    #0D1526;
    --sidebar-w:     220px;
    --border:        #2D3A4A;
    --border-focus:  #3B82F6;
    --accent:        #3B82F6;
    --accent-hover:  #2563EB;
    --accent-subtle: rgba(59, 130, 246, 0.1);
    --text-primary:  #F1F5F9;
    --text-secondary:#94A3B8;
    --text-muted:    #64748B;
    --success:       #10B981;
    --error:         #EF4444;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius:    8px;
    --radius-lg: 12px;
}

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

html {
    font-size: 16px;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100%;
}

/* ── App Shell ──────────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-tagline {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.15rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
}

.nav-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sidebar-footer::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

/* ── Main Content ───────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* ── Views ──────────────────────────────────────────────────────────────── */

.view {
    display: none;
    padding: 2rem 2.5rem;
    max-width: 860px;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: 1.75rem;
}

.view-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.view-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ── Section Titles ─────────────────────────────────────────────────────── */

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* ── Form ───────────────────────────────────────────────────────────────── */

.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.label-optional {
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

.form-group input,
.form-group select,
.form-group textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    padding: 0.65rem 0.85rem;
    transition: border-color 0.2s ease;
    width: 100%;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.5rem;
}

/* ── Generate Button ────────────────────────────────────────────────────── */

.btn-generate {
    width: 100%;
    padding: 0.85rem;
    margin-top: 0.5rem;
    background: var(--accent);
    color: #fff;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-generate:hover  { background: var(--accent-hover); }
.btn-generate:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}

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

/* ── Results ────────────────────────────────────────────────────────────── */

.results-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Tabs */

.tabs {
    display: flex;
    gap: 0.25rem;
    margin: 0 0 1rem;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 0.6rem 1.1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.tab:hover  { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel        { display: none; }
.tab-panel.active { display: block; }

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

.panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-copy {
    padding: 0.35rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-copy:hover  { background: var(--border); color: var(--text-primary); }
.btn-copy.copied { background: var(--success); border-color: var(--success); color: #fff; }

.btn-action {
    padding: 0.35rem 0.85rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-action:hover { background: var(--accent); color: #fff; }

.panel-body {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ── Error ──────────────────────────────────────────────────────────────── */

.error-message {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    color: var(--error);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* ── Auth Gate ──────────────────────────────────────────────────────────── */

#auth-gate {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.auth-logo    { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.auth-tagline { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2rem; }

#auth-password {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: var(--font);
    margin-bottom: 0.75rem;
    outline: none;
    transition: border-color 0.2s;
}

#auth-password:focus { border-color: var(--border-focus); }

#auth-submit {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.2s;
}

#auth-submit:hover { background: var(--accent-hover); }

#auth-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 0.75rem;
    display: none;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        width: 56px;
        min-width: 56px;
    }

    .sidebar-brand,
    .sidebar-tagline,
    .sidebar-footer,
    .nav-item span {
        display: none;
    }

    .sidebar-nav {
        padding: 0.75rem 0.5rem;
        align-items: center;
    }

    .nav-item {
        justify-content: center;
        padding: 0.75rem;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
    }

    .view {
        padding: 1.5rem 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.5rem 0.85rem;
    }
}
