:root {
    --bg-main: #0D1117;
    --bg-panel: #161B22;
    --bg-hover: #21262D;

    --border-color: #30363D;
    --border-highlight: #F48024;

    --text-main: #C9D1D9;
    --text-muted: #8B949E;

    --brand-orange: #F48024;
    --brand-blue: #0A95FF;
    --brand-blue-hover: #0074CC;
    --brand-gray: #3B4045;

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

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

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    padding: 0 20px;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.nav-list {
    list-style: none;
}

.nav-item {
    padding: 8px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-hover);
}

.nav-item.active {
    background-color: var(--bg-hover);
    border-right: 3px solid var(--brand-orange);
    color: #fff;
    font-weight: 500;
}

.nav-item .count {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tag-cloud {
    padding: 0 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background-color: rgba(10, 149, 255, 0.1);
    color: var(--brand-blue);
    border: 1px solid transparent;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover,
.tag.active {
    background-color: rgba(10, 149, 255, 0.2);
    border-color: rgba(10, 149, 255, 0.5);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Important for flex child to truncate properly */
}

/* Top Bar */
.top-bar {
    height: 60px;
    padding: 0 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-panel);
}

.search-container {
    position: relative;
    width: 400px;
    max-width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(10, 149, 255, 0.2);
}

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

.content-area::-webkit-scrollbar {
    width: 8px;
}

.content-area::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 400;
    color: #fff;
}

/* Buttons and Selects */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    outline: none;
}

.btn-primary {
    background-color: var(--brand-blue);
    color: white;
}

.btn-primary:hover {
    background-color: var(--brand-blue-hover);
}

.btn-secondary {
    background-color: var(--bg-main);
    border-color: var(--border-color);
    color: var(--text-main);
}

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

.btn-danger {
    background-color: transparent;
    border-color: #EF4444;
    color: #EF4444;
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.select-input {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
}

/* Answers Grid */
.answers-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.answer-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.answer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.answer-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--brand-blue);
    text-decoration: none;
    line-height: 1.3;
}

.answer-title:hover {
    color: var(--brand-blue-hover);
}

.answer-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rating-stars {
    color: var(--brand-orange);
    font-weight: bold;
    letter-spacing: 2px;
}

.answer-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.answer-url:hover {
    color: var(--brand-blue);
    text-decoration: underline;
}

.answer-card .tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.code-container {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-x: auto;
    max-height: 250px;
    overflow-y: auto;
}

.code-container::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.code-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.notes-container {
    font-size: 0.9rem;
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-left: 3px solid var(--brand-orange);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.notes-container p {
    margin-bottom: 8px;
}

.notes-container p:last-child {
    margin-bottom: 0;
}

.notes-container code {
    background-color: var(--bg-main);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.answer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 5px;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(2px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.flex-1 {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-group input,
.form-group textarea {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--brand-blue);
}

.input-with-action {
    display: flex;
    gap: 8px;
}

.code-font {
    font-family: var(--font-mono) !important;
    font-size: 0.85rem !important;
    white-space: pre;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--brand-blue);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .sidebar-nav {
        max-height: 200px;
    }
}