/* ========================================
   Docker Compose Builder — Rose Gold Theme
   ======================================== */

:root {
    --primary: #F43F5E;
    --primary-hover: #E11D48;
    --secondary: #FB7185;
    --accent: #38BDF8;
    --bg: #1A0C12;
    --bg-surface: #241018;
    --bg-elevated: #2E1520;
    --bg-input: #1F0E16;
    --border: #3E1F2C;
    --border-focus: #F43F5E;
    --text: #F1E4E8;
    --text-muted: #9B7A85;
    --text-dim: #6B5460;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

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

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

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

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

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

.header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}

.header-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--primary);
}

.btn-primary-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-color: transparent;
}

.btn-primary-header:hover {
    filter: brightness(1.1);
    color: #fff;
}

/* Main Layout */
.app-main {
    display: grid;
    grid-template-columns: 240px 1fr 320px;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 6px;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
}

.template-btn:hover {
    border-color: var(--primary);
    background: rgba(244, 63, 94, 0.08);
    color: var(--text);
    transform: translateY(-1px);
}

.template-icon {
    font-size: 1.3rem;
}

.template-name {
    font-size: 0.72rem;
    font-weight: 500;
}

/* Services List */
.services-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.service-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
}

.service-item:hover {
    border-color: var(--primary);
    background: rgba(244, 63, 94, 0.05);
}

.service-item.active {
    border-color: var(--primary);
    background: rgba(244, 63, 94, 0.1);
}

.service-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.service-item-name {
    flex: 1;
    font-family: var(--mono);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Validation */
.validation-panel {
    font-size: 0.82rem;
}

.validation-ok {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
}

.validation-error {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--error);
    padding: 4px 0;
    font-size: 0.8rem;
}

/* Editor Panel */
.editor-panel {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.editor-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
    color: var(--text-dim);
    text-align: center;
    padding: 40px;
}

.editor-placeholder .sub {
    font-size: 0.82rem;
}

.editor-content {
    padding: 20px;
    flex: 1;
}

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

.editor-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.btn-danger-sm {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
    padding: 6px 12px;
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

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

/* Tabs */
.editor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    padding: 8px 14px;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.etab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.etab-panel.active {
    display: block;
}

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

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

/* Form Groups */
.form-group {
    margin-bottom: 14px;
}

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

.form-group .optional {
    font-weight: 400;
    font-style: italic;
    color: var(--text-dim);
}

.form-group input,
.form-group select {
    width: 100%;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--mono);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}

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

.form-group input::placeholder {
    color: var(--text-dim);
}

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

.input-row input {
    flex: 1;
}

.btn-sm {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

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

/* KV Editor */
.kv-header {
    display: grid;
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.kv-header span {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.kv-row {
    display: grid;
    grid-template-columns: 1fr 1fr 36px;
    gap: 8px;
    margin-bottom: 6px;
    animation: fadeIn 0.15s ease;
}

.kv-row input {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 0.82rem;
    outline: none;
    transition: border-color var(--transition);
}

.kv-row input:focus {
    border-color: var(--border-focus);
}

.kv-row input::placeholder {
    color: var(--text-dim);
}

.btn-remove-row {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
}

.btn-remove-row:hover {
    color: var(--error);
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.08);
}

.btn-add-row {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    font-family: var(--font);
    cursor: pointer;
    width: 100%;
    margin-top: 4px;
    transition: all var(--transition);
}

.btn-add-row:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Tags */
.network-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.network-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

.network-tag button {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0 2px;
    transition: color var(--transition);
}

.network-tag button:hover {
    color: var(--error);
}

/* Depends Checkboxes */
.depends-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.85rem;
    color: var(--text);
}

.depends-check input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Preview Panel */
.preview-panel {
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.preview-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: var(--radius-xs);
    font-size: 0.78rem;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

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

.yaml-output {
    flex: 1;
    overflow: auto;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--secondary);
    white-space: pre;
    tab-size: 2;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

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

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

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

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.code-textarea {
    width: 100%;
    min-height: 260px;
    background: var(--bg-input);
    color: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
}

.code-textarea:focus {
    border-color: var(--border-focus);
}

.muted-text {
    color: var(--text-dim);
    font-size: 0.82rem;
    text-align: center;
    padding: 16px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    max-width: 300px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

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

@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

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

    .preview-panel {
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 300px;
    }
}