/* Reset and Base Styles */
/* NOTE: Theme variables are centralized in /app/css/theme.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Top Navigation Bar */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 1.5rem;
    max-width: 100%;
    gap: 1.5rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

.mobile-menu-toggle svg {
    display: block;
}

.mobile-analysis-toggle {
    display: none;
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 1180;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
    cursor: pointer;
}

.mobile-analysis-toggle:hover,
.mobile-analysis-toggle[aria-expanded="true"] {
    background: var(--bg-hover);
    color: var(--accent-blue);
}

.mobile-analysis-toggle[aria-expanded="true"] {
    z-index: 1210;
}

.mobile-analysis-toggle[hidden] {
    display: none !important;
}

.analysis-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(3px);
}

.analysis-panel-overlay.active {
    display: block;
}

.app-name {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.profile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    width: 32px;
    height: 32px;
}

.profile-icon:hover {
    background: var(--bg-hover);
}

.profile-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

/* Main Container */
.main-container {
    display: flex;
    flex-direction: row;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
}

/* Sidebar */
.sidebar {
    width: 60px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-right: 1px solid #e2e8f0;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 999;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sidebar.expanded {
    width: 240px;
}

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

.sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.sidebar-content {
    padding: 0.25rem 0;
    flex: 1;
    overflow-x: hidden;
}

.sidebar.expanded .sidebar-content {
    padding: 0.5rem 0;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
}

.menu-item {
    margin-bottom: 2px;
}

.menu-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.5rem;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin: 0 0.25rem;
    border-radius: 0.375rem;
}

.sidebar.expanded .menu-link {
    justify-content: flex-start;
    gap: 0.625rem;
    padding: 0.5rem 1rem;
    margin: 0 0.5rem;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 0;
    background: var(--accent-gradient);
    border-radius: 0 2px 2px 0;
    transition: height 0.2s ease;
}

.menu-link:hover {
    background: rgba(100, 116, 139, 0.1);
    color: #1e293b;
    transform: translateX(2px);
}

.menu-link:hover::before {
    height: 50%;
}

.menu-link.active {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-blue);
}

.menu-link.active::before {
    height: 60%;
}

.menu-link.active .menu-icon {
    color: var(--accent-blue);
    filter: drop-shadow(0 0 6px rgba(14, 165, 233, 0.4));
}

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
    transition: all 0.2s ease;
    color: currentColor;
}

.sidebar.expanded .menu-icon {
    width: 18px;
    height: 18px;
}

.menu-text {
    flex: 1;
    font-size: 0.8125rem;
    font-weight: 500;
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.3s ease;
}

.sidebar.expanded .menu-text {
    opacity: 1;
    width: auto;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 0.5rem;
}

.sidebar-toggle-btn:hover {
    background: rgba(100, 116, 139, 0.1);
    color: #1e293b;
}

.sidebar-toggle-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

/* Toggle icon visibility based on sidebar state */
.sidebar-toggle-btn .toggle-icon-expand {
    display: block;
}

.sidebar-toggle-btn .toggle-icon-collapse {
    display: none;
}

.sidebar.expanded .sidebar-toggle-btn .toggle-icon-expand {
    display: none;
}

.sidebar.expanded .sidebar-toggle-btn .toggle-icon-collapse {
    display: block;
}

.sidebar.expanded .sidebar-toggle-btn {
    justify-content: flex-end;
}

/* Main Content Wrapper */
.main-content-wrapper {
    flex: 1;
    margin-left: 60px;
    margin-right: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    min-height: 100vh;
    width: calc(100vw - 60px);
    max-width: none;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
    left: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded~.main-content-wrapper {
    margin-left: 240px;
    width: calc(100vw - 240px);
}

.main-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    animation: fadeIn 0.3s ease;
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        width: 240px;
    }

    .sidebar.open .menu-link {
        justify-content: flex-start;
        gap: 0.625rem;
        padding: 0.5rem 1rem;
        margin: 0 0.5rem;
    }

    .sidebar.open .menu-text {
        opacity: 1;
        width: auto;
    }

    .main-content-wrapper {
        margin-left: 0;
        width: 100%;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .nav-content {
        padding: 0 0.75rem;
        gap: 0.75rem;
    }

    .app-name {
        font-size: 1.125rem;
    }
}

@media (max-width: 1100px) {
    .mobile-analysis-toggle {
        display: flex;
    }
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 998;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   DARK THEME SUPPORT
   Using pure gray colors from theme.css
   ============================================ */

[data-theme="dark"] .sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border-color);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .sidebar::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

[data-theme="dark"] .menu-link {
    color: var(--text-secondary);
}

[data-theme="dark"] .menu-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

[data-theme="dark"] .menu-link.active {
    background: rgba(168, 85, 247, 0.15);
    color: var(--accent-primary);
}

[data-theme="dark"] .sidebar-toggle-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}
