:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

.hidden {
    display: none !important;
}

/* View Management */
.view {
    display: none;
    height: 100vh;
}

.view.active {
    display: flex;
}

/* Sub-View Management */
.sub-view {
    display: none;
}

.sub-view.active {
    display: block;
}

/* Grid-based sub-views need flex or grid when active */
#projects-grid.sub-view.active {
    display: grid;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
}

/* Login Page */
#login-view {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, #1e1b4b, var(--bg-dark));
}

.login-card {
    width: 100%;
    max-width: 450px;
    padding: 48px;
    animation: fadeIn 0.6s ease-out;
}

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

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

.logo-section {
    text-align: center;
    margin-bottom: 40px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    margin: 0 auto 16px;
    color: white;
}

.logo-section h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.logo-section p {
    color: var(--text-dim);
}

/* Forms */
.input-group {
    margin-bottom: 24px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
}

input,
select {
    width: 100%;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #334155;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
    filter: grayscale(0.8);
}

.onboarding-provider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.onboarding-provider-sublist {
    display: flex;
    gap: 8px;
    padding-left: 4px;
}

.onboarding-sub-btn {
    flex: 1;
    padding: 10px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.onboarding-sub-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.org-select-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.org-select-item {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.org-select-item:hover {
    background: var(--primary);
    transform: translateY(-2px);
}

.error-msg {
    color: #ef4444;
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

.success-msg {
    color: #22c55e;
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
}

.success-msg:empty,
.error-msg:empty {
    display: none;
}

.btn-upgrade {
    margin-top: 8px;
    width: 100%;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

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

.btn-upgrade:disabled {
    opacity: 0.5;
    cursor: default;
}

.account-links {
    margin-top: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
}

.account-links a {
    color: inherit;
    opacity: 0.6;
    text-decoration: none;
}

.account-links a:hover {
    opacity: 1;
}

.account-links .danger-link {
    color: #ef4444;
}

.auth-switch {
    margin-top: 20px;
    font-size: 14px;
    text-align: center;
    opacity: 0.8;
}

.auth-switch a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* Dashboard Sidebar */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.8);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 32px 16px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 48px;
    padding: 0 16px;
}

.mini-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.sidebar-header span {
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info {
    padding: 0 16px;
    margin-bottom: 32px;
}

#user-name-display {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.badge {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--primary);
}

.owner-badge {
    font-size: 9px;
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 8px;
}

.nav-links a {
    display: block;
    padding: 12px 16px;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.2s;
}

.nav-links li.active a,
.nav-links a:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.plan-info {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    font-size: 14px;
}

#plan-display {
    color: var(--primary);
    font-weight: 700;
}

/* Content Area */
.content-area {
    flex-grow: 1;
    padding: 48px;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 40px;
}

.top-bar .btn-primary {
    width: auto;
    padding: 12px 20px;
    font-size: 14px;
    white-space: nowrap;
}

#breadcrumbs {
    font-size: 14px;
    color: var(--text-dim);
    margin-top: 8px;
}

/* Projects Grid */
#projects-grid {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.project-card {
    padding: 32px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--primary);
}

.project-card h3 {
    margin-bottom: 12px;
    font-size: 20px;
}

.project-card p {
    color: var(--text-dim);
    font-size: 14px;
}

/* Theme toggle button — fixed top-right, visible on every view */
.btn-theme-toggle {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 9999;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-main);
    line-height: 1;
    box-shadow: var(--glass-shadow);
    transition: border-color 0.2s, background 0.2s;
}

.btn-theme-toggle:hover {
    border-color: var(--primary);
}

/* Light mode overrides */
body.light-mode {
    --bg-dark: #f1f5f9;
    --card-bg: rgba(255, 255, 255, 0.92);
    --text-main: #0f172a;
    --text-dim: #64748b;
    --border: rgba(0, 0, 0, 0.09);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
}

body.light-mode #login-view {
    background: radial-gradient(circle at top right, #e0e7ff, #f1f5f9);
}

body.light-mode #org-select-view {
    background: radial-gradient(circle at top right, #e0e7ff, #f1f5f9);
}

body.light-mode .sidebar {
    background: rgba(255, 255, 255, 0.92);
}

body.light-mode input,
body.light-mode select {
    background: rgba(241, 245, 249, 0.9);
    color: var(--text-main);
}

body.light-mode .plan-info {
    background: rgba(0, 0, 0, 0.04);
}

body.light-mode .file-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

body.light-mode .org-select-item {
    background: rgba(0, 0, 0, 0.04);
}

/* Modal styles extracted to modals.css */
