/* ============================================
   Makefile Generator — Styles
   Theme: Dark mode + Emerald Green palette
   ============================================ */

/* --- Design Tokens --- */
:root {
    --primary: #00B894;
    --primary-hover: #00D4A8;
    --primary-dim: rgba(0, 184, 148, 0.15);
    --secondary: #55EFC4;
    --accent: #FDCB6E;
    --accent-dim: rgba(253, 203, 110, 0.15);
    --bg: #0A1A14;
    --bg-card: rgba(16, 40, 30, 0.6);
    --bg-hover: rgba(0, 184, 148, 0.08);
    --bg-input: rgba(10, 26, 20, 0.8);
    --surface: rgba(20, 50, 38, 0.5);
    --border: rgba(0, 184, 148, 0.12);
    --border-focus: rgba(0, 184, 148, 0.5);
    --text: #E8F5F0;
    --text-secondary: #8FBFAE;
    --text-dim: #5A8A78;
    --danger: #E17055;
    --danger-hover: #F06040;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: 250ms ease;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --glass: blur(16px) saturate(180%);
}

/* --- Reset --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
}

/* Subtle radial glow */
body::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(0, 184, 148, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* --- Header --- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: rgba(10, 26, 20, 0.85);
    backdrop-filter: var(--glass);
    border-bottom: 1px solid var(--border);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    border-left: 1px solid var(--border);
    padding-left: 16px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #00D4A8);
    color: #0A1A14;
    box-shadow: 0 2px 12px rgba(0, 184, 148, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.45);
}

.btn-secondary {
    background: var(--primary-dim);
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(0, 184, 148, 0.2);
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 12px;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.btn-icon {
    background: transparent;
    color: var(--primary);
    padding: 6px;
    border-radius: var(--radius-xs);
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--primary-dim);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    padding: 4px;
    border-radius: var(--radius-xs);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-danger:hover {
    background: rgba(225, 112, 85, 0.15);
    color: var(--danger-hover);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- Main Layout --- */
.app-main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* --- Editor Panel --- */
.editor-panel {
    padding: 20px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    backdrop-filter: var(--glass);
}

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

.section-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.section-actions {
    display: flex;
    gap: 4px;
}

.items-list {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 40px;
}

/* --- Variable Item --- */
.variable-item {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid transparent;
    transition: all var(--transition);
    animation: fadeSlideIn 300ms ease;
}

.variable-item:hover {
    border-color: var(--border);
}

.variable-item:hover .btn-danger {
    opacity: 1;
}

.variable-item .equals {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
}

/* --- Target Item --- */
.target-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid transparent;
    transition: all var(--transition);
    animation: fadeSlideIn 300ms ease;
}

.target-item:hover {
    border-color: var(--border);
}

.target-item:hover .btn-danger {
    opacity: 1;
}

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

.target-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.target-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.phony-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-dim);
    color: var(--accent);
    white-space: nowrap;
}

.target-deps {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.target-deps label {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
}

.target-recipe {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.target-recipe label {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* --- Inputs --- */
input[type="text"],
textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 7px 10px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.1);
}

input[type="text"]::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

/* Checkbox (for PHONY) */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.checkbox-label input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0A1A14;
    font-size: 0.7rem;
    font-weight: 700;
}

.checkbox-label input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* --- Preview Panel --- */
.preview-panel {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
}

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

.preview-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.preview-meta {
    display: flex;
    gap: 8px;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--primary-dim);
    color: var(--primary);
}

.code-preview {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow: auto;
    backdrop-filter: var(--glass);
}

.code-preview code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre;
    tab-size: 4;
}

/* Syntax highlighting classes */
.code-preview .hl-comment {
    color: var(--text-dim);
    font-style: italic;
}

.code-preview .hl-variable {
    color: var(--accent);
}

.code-preview .hl-target {
    color: var(--primary);
    font-weight: 600;
}

.code-preview .hl-phony {
    color: var(--secondary);
}

.code-preview .hl-recipe {
    color: var(--text-secondary);
}

.code-preview .hl-operator {
    color: var(--danger);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 12, 8, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 200ms ease;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: rgba(16, 40, 30, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: scaleIn 250ms ease;
}

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

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

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

.preset-categories {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.preset-cat-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-cat-btn:hover,
.preset-cat-btn.active {
    background: var(--primary-dim);
    border-color: var(--primary);
    color: var(--primary);
}

.preset-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

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

.preset-item-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.preset-item-info p {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.preset-item .btn {
    flex-shrink: 0;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--primary);
    color: #0A1A14;
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity 300ms ease, transform 300ms ease;
    z-index: 300;
    pointer-events: none;
}

.toast[hidden] {
    display: block;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

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

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 184, 148, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 184, 148, 0.35);
}

/* --- Empty State --- */
.empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.82rem;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: none;
    }

    .preview-panel {
        max-height: none;
        min-height: 300px;
    }

    .header-subtitle {
        display: none;
    }
}

@media (max-width: 540px) {
    .app-header {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .editor-panel,
    .preview-panel {
        padding: 14px;
    }

    .variable-item {
        grid-template-columns: 1fr auto 1fr auto;
    }
}