/* ========================================================
   shadcn/ui Slate/Zinc Dark Theme for Docker Compose UI Editor
   ======================================================== */

:root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --card-foreground: #fafafa;
    --popover: #09090b;
    --popover-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --secondary: #27272a;
    --secondary-foreground: #fafafa;
    --muted: #18181b;
    --muted-foreground: #a1a1aa;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #7f1d1d;
    --destructive-foreground: #fef2f2;
    --success: #14532d;
    --success-foreground: #f0fdf4;
    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;
    --radius: 0.5rem;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

/* 1. Global Resets & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 2. Header */
.header {
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    justify-self: start;
}

.project-name-group input.form-input-header {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 0.875rem;
    width: 250px;
    background-color: var(--muted);
    color: var(--foreground);
    transition: all 0.2s ease;
}

.project-name-group input.form-input-header:focus {
    border-color: var(--ring);
    outline: none;
}

.save-status {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    background-color: var(--muted);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.logo i {
    color: #38bdf8; /* light blue accent for docker */
    font-size: 1.5rem;
}

.unsaved-indicator {
    display: none;
    color: #f59e0b; /* amber-500 */
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
}

.unsaved-indicator.show {
    display: inline;
}

/* 3. Button System (shadcn/ui style) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn.btn-full {
    width: 100%;
}

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

.btn-primary:hover {
    background-color: #e4e4e7;
    border-color: #e4e4e7;
}

.btn-secondary {
    background-color: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-secondary:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.btn-success {
    background-color: var(--success);
    color: var(--success-foreground);
    border: 1px solid rgba(20, 83, 45, 0.5);
}

.btn-success:hover {
    background-color: #166534;
}

.btn-danger {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
    border: 1px solid rgba(127, 29, 29, 0.5);
}

.btn-danger:hover {
    background-color: #991b1b;
}

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

.btn-save:hover {
    background-color: var(--accent);
}

.btn-save.unsaved {
    background-color: #d97706; /* amber-600 */
    border-color: #d97706;
    color: white;
    animation: pulse 2s infinite;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--muted-foreground);
    padding: 0.375rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(217, 119, 6, 0); }
}

/* 4. Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 280px 1fr 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    height: calc(100vh - 60px);
}

/* 5. Sidebar */
.sidebar {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-box {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background-color: var(--muted);
    color: var(--foreground);
    outline: none;
    transition: all 0.15s ease;
}

.search-box:focus {
    border-color: var(--ring);
}

.sidebar-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.section {
    padding: 0 0.5rem;
    margin-bottom: 1rem;
}

.section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    cursor: pointer;
    border-radius: var(--radius);
    background-color: var(--muted);
    border: 1px solid var(--border);
    margin-bottom: 0.5rem;
    transition: all 0.15s ease;
}

.section-header:hover {
    background-color: var(--accent);
}

.section-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-title i {
    color: var(--muted-foreground);
}

.section-actions {
    display: flex;
}

.item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.item-card .item-actions {
    display: none;
}

.item-card:hover .item-actions,
.item-card.active .item-actions {
    display: flex;
    gap: 0.25rem;
}

.item-card:hover .item-name,
.item-card.active .item-name {
    font-weight: 600;
}

.item-card.active .item-name {
    color: var(--foreground);
}

.item-card:hover {
    background-color: var(--muted);
    border-color: var(--border);
}

.item-card.active {
    background-color: var(--accent);
    border-color: var(--border);
    border-left: 3px solid var(--ring);
}

.item-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--muted-foreground);
}

.item-card.active .item-name {
    color: var(--foreground);
}

/* 6. Editor & Preview Panels */
.editor-panel, .preview-panel {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.preview-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.preview-content {
    flex-grow: 1;
    overflow: auto;
    position: relative;
}

.yaml-preview {
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    height: 100%;
    margin: 0;
    background-color: var(--background);
    color: #e2e8f0;
    border: none;
    outline: none;
}

.yaml-editor {
    width: 100%;
    height: 100%;
    padding: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.6;
    border: none;
    outline: none;
    resize: none;
    background-color: var(--muted);
    color: var(--foreground);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
    padding: 2rem;
    color: var(--muted-foreground);
}

.welcome-message i {
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 1.25rem;
}

.welcome-message h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

/* 7. Modal System */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--background);
    margin: 6% auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 90%;
    max-width: 580px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    animation: modalSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content.wide {
    max-width: 850px;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

.close {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: color 0.15s;
}

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

.modal-body {
    padding: 1.25rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* 8. Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.form-input, .form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background-color: var(--muted);
    color: var(--foreground);
    outline: none;
    transition: border-color 0.15s;
}

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

.dynamic-list {
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.dynamic-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.dynamic-item:last-child {
    margin-bottom: 0;
}

/* 9. Template Grid */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.tab-button {
    padding: 8px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
}

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

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

#templateSearchBox {
    margin-bottom: 1rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.template-card {
    border: 1px solid var(--border);
    background-color: var(--muted);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.template-card:hover {
    border-color: var(--ring);
    background-color: var(--accent);
}

.template-icon {
    font-size: 1.5rem;
    color: var(--ring);
    margin-bottom: 0.75rem;
}

.template-tags {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.template-tag {
    background-color: var(--accent);
    color: var(--muted-foreground);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

/* Image Repository Browser */
.image-repo-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.image-search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.image-search-section .search-box {
    flex: 1;
    margin-bottom: 0;
}

.image-results {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--muted);
}

.image-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.image-result-item:hover {
    background-color: var(--accent);
}

.image-result-item:last-child {
    border-bottom: none;
}

.image-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.image-result-name {
    font-weight: 600;
    color: var(--foreground);
}

.image-result-stars {
    color: var(--muted-foreground);
    font-size: 0.8125rem;
}

.image-result-description {
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.image-result-tags {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.image-result-tag {
    background-color: var(--accent);
    color: var(--muted-foreground);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.image-loading, .image-empty {
    text-align: center;
    padding: 2rem;
    color: var(--muted-foreground);
}

.image-error {
    text-align: center;
    padding: 1.5rem;
    color: var(--destructive-foreground);
    background-color: var(--destructive);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.badge-official {
    background-color: #0284c7;
    color: white;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.image-result-stats {
    display: flex;
    gap: 1rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

.search-score {
    background-color: var(--accent);
    color: var(--foreground);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
    opacity: 0.8;
}

.search-summary {
    background-color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.search-summary-text {
    color: var(--muted-foreground);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-summary-text i {
    color: var(--ring);
}

/* Input with button */
.input-with-button {
    display: flex;
    gap: 0.5rem;
}

.input-with-button .form-input {
    flex: 1;
}

.browse-image-btn {
    background-color: var(--secondary);
    color: var(--foreground);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.browse-image-btn:hover {
    background-color: var(--accent);
}

/* Dependencies styling */
.dependencies-list {
    background-color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.dependency-item {
    margin-bottom: 0.75rem;
}

.dependency-item:last-child {
    margin-bottom: 0;
}

.dependency-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.dependency-row:hover {
    border-color: var(--ring);
}

.dependency-name {
    flex: 1;
    font-weight: 500;
    color: var(--foreground);
}

.dependency-condition {
    min-width: 180px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    background-color: var(--muted);
    color: var(--foreground);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    outline: none;
}

.dependency-condition:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.help-text {
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

/* 10. Notifications */
#notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
    animation: slideInUp 0.2s ease;
}

@keyframes slideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.notification-success { background-color: var(--success); color: var(--success-foreground); border: 1px solid rgba(20, 83, 45, 0.5); }
.notification-error { background-color: var(--destructive); color: var(--destructive-foreground); border: 1px solid rgba(127, 29, 29, 0.5); }
.notification-info { background-color: var(--accent); color: var(--accent-foreground); border: 1px solid var(--border); }

/* 11. Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--background);
}
::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--ring);
}

/* 12. Responsive */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 260px 1fr;
    }
    .preview-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .main-container {
        grid-template-columns: 1fr;
        height: auto;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    .sidebar {
        height: auto;
    }
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0 0.75rem;
    }
    .save-status {
        position: static;
        transform: none;
        order: -1;
        width: 100%;
        justify-content: center;
    }
}

/* Add Button Container */
.add-button-container {
    position: relative;
    width: 100%;
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    padding: 0.25rem;
    margin-top: 0.25rem;
    display: none;
    flex-direction: column;
    z-index: 2000;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    background: none;
    border: none;
    padding: 0.5rem 0.75rem;
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.15s ease;
}

.dropdown-item i {
    color: var(--muted-foreground);
}

.dropdown-item:hover {
    background-color: var(--accent);
    color: var(--foreground);
}

.dropdown-item:hover i {
    color: var(--foreground);
}

/* Section count pill */
.section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--accent);
    color: var(--foreground);
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    min-width: 1.25rem;
    text-align: center;
    margin-left: auto;
    margin-right: 0.5rem;
    border: 1px solid var(--border);
}

/* Editor Panel Styles */
.editor-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.editor-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex-grow: 1;
}

.editor-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    align-items: start;
}

.form-group.span-2 {
    grid-column: span 2 / span 2;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    border-radius: 0.25rem;
    transition: background-color 0.15s ease;
}

.checkbox-item:hover {
    background-color: var(--muted);
}

.checkbox-item label {
    cursor: pointer;
    user-select: none;
    flex: 1;
    color: var(--foreground);
}

.checkbox-item input[type="checkbox"] {
    margin: 0;
    width: 15px;
    height: 15px;
    accent-color: var(--ring);
}

.empty-list-msg {
    color: var(--muted-foreground);
    font-style: italic;
    padding: 1rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background-color: var(--background);
}

h4.mt-4 {
    margin-top: 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
}

.dynamic-list .remove-btn {
    margin-left: auto;
}

.sidebar-header .form-input {
    margin-top: 0.5rem;
}