/* General Bots Suite - Base Layout & Theme Styles */
/* Extracted from base.html inline styles - organized and deduplicated */

/* ============================================ */
/* THEME VARIABLES (6 THEMES)                   */
/* ============================================ */

:root {
    /* Default Dark Theme */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
}

[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text: #f8fafc;
    --text-secondary: #94a3b8;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
}

[data-theme="blue"] {
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-light: rgba(14, 165, 233, 0.1);
    --bg: #0c1929;
    --surface: #1a2f47;
    --surface-hover: #254063;
    --border: #2d4a6f;
}

[data-theme="purple"] {
    --primary: #a855f7;
    --primary-hover: #9333ea;
    --primary-light: rgba(168, 85, 247, 0.1);
    --bg: #1a0a2e;
    --surface: #2d1b4e;
    --surface-hover: #3d2566;
    --border: #4c2f7e;
}

[data-theme="green"] {
    --primary: #22c55e;
    --primary-hover: #16a34a;
    --primary-light: rgba(34, 197, 94, 0.1);
    --bg: #0a1f15;
    --surface: #14332a;
    --surface-hover: #1e4a3d;
    --border: #28604f;
}

[data-theme="orange"] {
    --primary: #f97316;
    --primary-hover: #ea580c;
    --primary-light: rgba(249, 115, 22, 0.1);
    --bg: #1a1008;
    --surface: #2d1c0f;
    --surface-hover: #442a16;
    --border: #5c3a1e;
}

/* ============================================ */
/* BASE RESETS                                  */
/* ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================ */
/* APP HEADER                                   */
/* ============================================ */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================ */
/* LOGO                                         */
/* ============================================ */

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ============================================ */
/* HEADER BUTTONS                               */
/* ============================================ */

.header-btn {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ============================================ */
/* USER AVATAR                                  */
/* ============================================ */

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
}

/* ============================================ */
/* APPS MENU & DROPDOWNS                        */
/* ============================================ */

.apps-menu,
.settings-menu {
    position: relative;
}

.apps-dropdown,
.settings-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    min-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 1001;
}

.apps-dropdown.show,
.settings-panel.show {
    display: block;
}

.apps-dropdown-title,
.settings-panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

/* ============================================ */
/* APPS GRID                                    */
/* ============================================ */

.apps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s;
}

.app-item:hover {
    background: var(--surface-hover);
}

.app-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.app-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.app-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* ============================================ */
/* SETTINGS PANEL                               */
/* ============================================ */

.settings-panel {
    width: 320px;
    max-height: 80vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 1.25rem;
}

.settings-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 0.75rem 0;
}

/* ============================================ */
/* THEME SELECTOR                               */
/* ============================================ */

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.theme-option {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    overflow: hidden;
}

.theme-option:hover {
    transform: scale(1.05);
}

.theme-option.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.theme-option-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.theme-option-header {
    height: 30%;
    display: flex;
    align-items: center;
    padding: 0.25rem;
}

.theme-option-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 2px;
}

.theme-option-body {
    flex: 1;
    padding: 0.25rem;
}

.theme-option-line {
    height: 4px;
    border-radius: 2px;
    margin-bottom: 3px;
}

.theme-option-name {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    font-size: 0.6rem;
    text-align: center;
    color: inherit;
}

/* Theme Preview Colors */
.theme-dark .theme-option-inner { background: #0f172a; color: #f8fafc; }
.theme-dark .theme-option-header { background: #1e293b; }
.theme-dark .theme-option-dot { background: #3b82f6; }
.theme-dark .theme-option-line { background: #334155; }

.theme-light .theme-option-inner { background: #f8fafc; color: #1e293b; }
.theme-light .theme-option-header { background: #ffffff; }
.theme-light .theme-option-dot { background: #3b82f6; }
.theme-light .theme-option-line { background: #e2e8f0; }

.theme-blue .theme-option-inner { background: #0c1929; color: #f8fafc; }
.theme-blue .theme-option-header { background: #1a2f47; }
.theme-blue .theme-option-dot { background: #0ea5e9; }
.theme-blue .theme-option-line { background: #2d4a6f; }

.theme-purple .theme-option-inner { background: #1a0a2e; color: #f8fafc; }
.theme-purple .theme-option-header { background: #2d1b4e; }
.theme-purple .theme-option-dot { background: #a855f7; }
.theme-purple .theme-option-line { background: #4c2f7e; }

.theme-green .theme-option-inner { background: #0a1f15; color: #f8fafc; }
.theme-green .theme-option-header { background: #14332a; }
.theme-green .theme-option-dot { background: #22c55e; }
.theme-green .theme-option-line { background: #28604f; }

.theme-orange .theme-option-inner { background: #1a1008; color: #f8fafc; }
.theme-orange .theme-option-header { background: #2d1c0f; }
.theme-orange .theme-option-dot { background: #f97316; }
.theme-orange .theme-option-line { background: #5c3a1e; }

/* ============================================ */
/* SETTINGS SHORTCUTS                           */
/* ============================================ */

.settings-shortcut {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s;
}

.settings-shortcut:hover {
    background: var(--surface-hover);
}

.settings-shortcut-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.settings-shortcut-text {
    flex: 1;
}

.settings-shortcut-title {
    font-size: 0.875rem;
    font-weight: 500;
}

.settings-shortcut-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.settings-shortcut-arrow {
    color: var(--text-secondary);
}

/* ============================================ */
/* QUICK TOGGLES                                */
/* ============================================ */

.quick-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
}

.quick-toggle:hover {
    background: var(--surface-hover);
}

.quick-toggle-label {
    font-size: 0.875rem;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch.active::after {
    transform: translateX(18px);
}

/* ============================================ */
/* MAIN CONTENT AREA                            */
/* ============================================ */

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#main-content {
    flex: 1;
    overflow: auto;
}

/* ============================================ */
/* HTMX INDICATORS                              */
/* ============================================ */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--bg-rgb, 0, 0, 0), 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.htmx-request .loading-overlay {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner-large {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================ */
/* ERROR STATES                                 */
/* ============================================ */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.error-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    color: var(--error);
}

.error-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.error-state-message {
    margin-bottom: 20px;
    max-width: 400px;
}

.error-state-actions {
    display: flex;
    gap: 12px;
}

.btn-retry {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-retry:hover {
    filter: brightness(1.1);
}

.btn-retry:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-retry .spinner {
    width: 16px;
    height: 16px;
}

/* ============================================ */
/* SKELETON LOADING                             */
/* ============================================ */

.skeleton {
    background: linear-gradient(90deg, var(--border) 25%, var(--surface-hover) 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-card {
    height: 120px;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================ */
/* SPINNER ANIMATION                            */
/* ============================================ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================ */
/* NOTIFICATIONS                                */
/* ============================================ */

.notifications-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 9999;
    max-width: 400px;
}

.notification {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

.notification.success { border-left: 3px solid var(--success); }
.notification.error { border-left: 3px solid var(--error); }
.notification.warning { border-left: 3px solid var(--warning); }
.notification.info { border-left: 3px solid var(--info); }

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

/* ============================================ */
/* ACCESSIBILITY                                */
/* ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    text-decoration: none;
    border-radius: 0 0 8px 0;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.htmx-request [aria-busy] {
    opacity: 0.7;
}

/* ============================================ */
/* RESPONSIVE                                   */
/* ============================================ */

@media (max-width: 768px) {
    .logo span {
        display: none;
    }
    
    .apps-dropdown,
    .settings-panel {
        width: calc(100vw - 2rem);
        right: -0.5rem;
    }
    
    .theme-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
