/* InsightWeave Frontend Styles - Editorial Dark Theme */

:root {
    --bg-primary: #111110;
    --bg-secondary: #1a1a18;
    --bg-tertiary: #242422;
    --bg-card: #1e1e1c;
    --bg-hover: #2a2a28;
    --bg-input: #1c1c1a;

    --text-primary: #e8e6e0;
    --text-secondary: #a09d95;
    --text-muted: #6b6862;
    --text-inverse: #111110;

    --accent: #d4a853;
    --accent-hover: #e6be6a;
    --accent-dim: #3d3522;
    --accent-glow: rgba(212, 168, 83, 0.15);

    --danger: #c44e4e;
    --danger-hover: #d96666;
    --success: #5a9e6f;
    --info: #5a8fca;

    --border: #2e2d29;
    --border-light: #3a3934;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-sans: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Lora', 'Georgia', 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=JetBrains+Mono:wght@400;500&display=swap');

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

.hidden { display: none !important; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--accent-hover);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    font-family: var(--font-sans);
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--accent);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.btn-accent:hover {
    opacity: 0.85;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: all var(--transition);
    outline: none;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input::placeholder {
    color: var(--text-muted);
}

textarea.input {
    resize: vertical;
    min-height: 100px;
    line-height: 1.7;
}

.label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
}

.card:hover {
    border-color: var(--border-light);
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.badge-success {
    background: rgba(90, 158, 111, 0.15);
    color: var(--success);
}

.badge-info {
    background: rgba(90, 143, 202, 0.15);
    color: var(--info);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

.slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.toast {
    position: fixed;
    top: 24px;
    right: 24px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
}

.toast-success {
    background: #1a3d2a;
    border: 1px solid var(--success);
    color: #8fd4a0;
}

.toast-error {
    background: #3d1a1a;
    border: 1px solid var(--danger);
    color: #d48f8f;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Status dot */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px rgba(90, 158, 111, 0.5);
}

.status-dot.idle {
    background: var(--text-muted);
}

/* ===== Mobile Responsive ===== */

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.hamburger-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background var(--transition);
}

.hamburger-btn:hover {
    background: var(--bg-hover);
}

.mobile-page-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 149;
}

.sidebar-backdrop.visible {
    display: block;
}

@media (max-width: 768px) {
    .app-layout,
    .settings-page,
    .admin-layout {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .mobile-topbar {
        display: flex;
    }

    .app-layout > .sidebar,
    .settings-page > .sidebar,
    .admin-layout > .admin-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 150;
        height: 100vh;
        height: 100dvh;
        width: 220px;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        display: none;
    }

    .app-layout > .sidebar.mobile-open,
    .settings-page > .sidebar.mobile-open,
    .admin-layout > .admin-sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
        display: flex;
    }

    .main-content,
    .admin-main,
    .writer-main {
        width: 100%;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .modal-overlay .modal,
    .modal-overlay .modal-box {
        max-width: 92vw;
        max-height: 85vh;
        overflow-y: auto;
    }

    .toast {
        top: auto;
        bottom: 24px;
        right: 16px;
        left: 16px;
        max-width: none;
    }

    .container {
        padding: 0 16px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.875rem;
    }

    .card {
        padding: 18px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 0;
    }

    .page-header h2 {
        display: none;
    }
}

body.embed-mode .sidebar,
body.embed-mode .sidebar-backdrop,
body.embed-mode .mobile-topbar { display: none !important; }
