@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #21252f;
    --bg-hover: #282d3a;
    --bg-input: #181b24;
    --border: #2d3348;
    --border-focus: #5b6abf;
    --text-primary: #e8eaf0;
    --text-secondary: #8b92a8;
    --text-muted: #5c6380;
    --accent: #6c7ae0;
    --accent-hover: #7b88e8;
    --accent-glow: rgba(108, 122, 224, 0.15);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.1);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.08);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.08);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Layout ---- */
.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

/* ---- Header ---- */
.header {
    grid-column: 1 / -1;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #9f7aea);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.header h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.header h1 span {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 13px;
    margin-left: 8px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Sidebar ---- */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.sidebar-section {
    padding: 0 14px;
    margin-bottom: 20px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 0 10px;
    margin-bottom: 6px;
}

.solution-list {
    list-style: none;
}

.solution-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}

.solution-item:hover {
    background: var(--bg-hover);
}

.solution-item.active {
    background: var(--accent-glow);
    border: 1px solid rgba(108, 122, 224, 0.25);
}

.solution-item.active .solution-icon {
    background: var(--accent);
    color: white;
}

.solution-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    transition: var(--transition);
}

.solution-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.solution-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
    background: var(--bg-primary);
    padding: 1px 7px;
    border-radius: 10px;
}

.global-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.global-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.global-item.active {
    background: var(--warning-bg);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

.add-solution-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 13px;
    background: none;
    border: 1px dashed var(--border);
    width: 100%;
    margin-top: 6px;
}

.add-solution-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-glow);
}

/* ---- Main Content ---- */
.main {
    padding: 24px 32px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
}

.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}

.main-header h2 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.main-header h2 .badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 3px 10px;
    border-radius: 10px;
    margin-left: 10px;
    vertical-align: middle;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(108, 122, 224, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.15);
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.15);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ---- File List ---- */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.file-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.file-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
    transform: translateY(-2px);
}

.file-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.file-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-glow), rgba(159, 122, 234, 0.1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    word-break: break-word;
}

.file-path {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Fira Code', 'Cascadia Code', monospace;
}

.file-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.file-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: none;
}

.file-card:hover .file-card-actions {
    display: flex;
    gap: 4px;
}

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 24px;
    background: linear-gradient(135deg, rgba(108, 122, 224, 0.02), rgba(159, 122, 234, 0.02));
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 24px rgba(108, 122, 224, 0.1);
}

.upload-zone-icon {
    font-size: 44px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.upload-zone h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.upload-zone p {
    font-size: 13px;
    color: var(--text-muted);
}

.upload-zone input[type="file"] {
    display: none;
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 720px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s ease;
}

.modal-backdrop.show .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ---- Document Preview ---- */
.doc-preview {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    font-size: 13px;
    line-height: 1.75;
    white-space: pre-wrap;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    max-height: 60vh;
    overflow-y: auto;
    color: var(--text-secondary);
}

/* ---- Search ---- */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box input {
    width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: var(--transition);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91, 106, 191, 0.15);
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}

/* ---- Input ---- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(91, 106, 191, 0.15);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b92a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px 18px;
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    max-width: 360px;
    margin: 0 auto;
}

/* ---- Stats Bar ---- */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    flex: 1;
    min-width: 0;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;
    background: linear-gradient(135deg, var(--accent), #9f7aea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Loading ---- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main {
        padding: 16px;
    }

    .file-grid {
        grid-template-columns: 1fr;
    }

}

/* ---- Workspaces Dashboard SPA ---- */

/* Tweak the main view headers */
.workspace-header {
    flex-shrink: 0;
}

.ws-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.ws-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.ws-tab:hover {
    color: var(--text-primary);
}

.ws-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Kanban Board Layout */
.kanban-col {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    min-width: 320px;
    max-width: 350px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.kanban-col-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    background: var(--bg-card);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.kanban-count {
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
}

.kanban-list {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Task Card */
.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: default;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.kanban-card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
}

.k-card-title {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.4;
    word-break: break-word;
}

.k-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.k-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
}

.k-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.k-tag {
    background: var(--bg-primary);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.k-tag.priority-critical {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border-color: rgba(248, 113, 113, 0.2);
}

.k-tag.priority-high {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
    border-color: rgba(251, 191, 36, 0.2);
}

.k-tag.category-bugfix {
    color: #f17a7a;
}
.k-tag.category-feature {
    color: #4ade80;
}
.k-tag.category-refactor {
    color: #a78bfa;
}

/* Timeline */
.timeline {
    border-left: 2px solid var(--border);
    padding-left: 20px;
    position: relative;
    max-width: 800px;
}

.tl-item {
    position: relative;
    margin-bottom: 24px;
}

.tl-dot {
    position: absolute;
    left: -26px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    top: 6px;
    box-shadow: 0 0 0 4px var(--bg-primary);
}

.tl-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-family: inherit;
}

.tl-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.tl-title {
    font-size: 13px;
    font-weight: 500;
}

/* Table overrides for Workspace List */
.table-container th {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.table-container td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.table-container tr:hover td {
    background: var(--bg-hover);
}