:root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --card-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --secondary-foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;
    --radius: 0.5rem;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow: auto;
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--foreground);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    .desktop-only {
        display: none;
    }
}

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
        height: calc(100vh - 57px); /* Subtract header height */
    }
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    flex-shrink: 0;
    transition: transform 0.3s ease-in-out;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 57px;
        left: 0;
        width: 100%;
        height: calc(100vh - 57px);
        z-index: 90;
        transform: translateX(-100%);
        border-right: none;
    }
    .sidebar.open {
        transform: translateX(0);
    }
}

/* Floating Action Button for Suggestions */
.btn-floating {
    position: absolute;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: none; /* Hidden by default, shown when suggestion exists */
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition:
        transform 0.2s,
        opacity 0.2s;
}

.btn-floating:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .btn-floating.visible {
        display: flex;
    }
}

@media (min-width: 769px) {
    .btn-floating.visible {
        display: none;
    }
}

.sidebar-header {
    margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
    .sidebar-header {
        margin-bottom: 1rem;
    }
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.brand {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0.2rem 0 0 0;
}

.settings {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-grow: 1;
}

@media (max-width: 768px) {
    .settings {
        gap: 1rem;
        margin-bottom: 1rem;
    }
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.value-badge {
    font-family: monospace;
    font-size: 0.75rem;
    background: var(--secondary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--muted-foreground);
}

/* Styled Inputs */
.select-input {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    padding: 0.5rem;
    font-size: 0.875rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-input:focus {
    border-color: var(--ring);
}

/* Custom Slider Styling */
.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: var(--secondary);
    border-radius: 2px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--background);
    box-shadow: 0 0 0 1px var(--border);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--background);
    box-shadow: 0 0 0 1px var(--border);
}

/* Button */
.btn {
    width: 100%;
    padding: 0.6rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    opacity: 0.9;
}

/* Sidebar Footer */
.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .sidebar-footer {
        display: none; /* Hide footer on mobile to save space */
    }
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #22c55e;
    border-radius: 50%;
}

.fetching .status-dot {
    background-color: #eab308;
    box-shadow: 0 0 8px #eab308;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
    100% {
        opacity: 1;
    }
}

/* Main Editor Area */
.editor-main {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    background-color: var(--background);
}

@media (max-width: 768px) {
    .editor-main {
        padding: 1rem;
        height: 100%;
        width: 100%;
    }
}

.editor-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
}

.editor-viewport {
    position: relative;
    height: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--card);
    overflow: hidden;
}

#editor,
#suggestion-overlay {
    width: 100%;
    height: 100%;
    padding: 2rem;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 1.1rem;
    line-height: 1.8;
    border: none;
    background: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    #editor,
    #suggestion-overlay {
        padding: 1rem;
        font-size: 1rem;
    }
}

#editor {
    position: relative;
    z-index: 2;
    color: var(--foreground);
    outline: none;
    resize: none;
    overflow-y: auto;
}

#suggestion-overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    color: var(--muted-foreground);
    pointer-events: none;
    opacity: 0.5;
    overflow: hidden;
    transition: transform 0.05s linear;
}
