/* App Enhanced - Shadcn Zinc Dark Theme */

:root {
    /* Shadcn Zinc Palette (Dark) */
    --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: #27272a;
    --muted-foreground: #a1a1aa;

    --accent: #27272a;
    --accent-foreground: #fafafa;

    --destructive: #7f1d1d;
    --destructive-foreground: #fafafa;

    --border: #27272a;
    --input: #27272a;
    --ring: #d4d4d8;

    --radius: 0.5rem;

    /* Overriding styles.css legacy variables */
    --primary-bg: var(--background);
    --secondary-bg: var(--card);
    --panel-bg: var(--card);
    --border-color: var(--border);
    --text-color: var(--foreground);
    --accent-color: var(--primary);
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: 'Inter', -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* --- Layout Structure --- */

/* Force flush layout */
.app-container,
.toolbar-and-content-wrapper,
.main-content {
    background-color: var(--background);
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
}

/* Toolbar */
.toolbar {
    background-color: var(--background);
    /* Solid bg for consistency */
    border-bottom: 1px solid var(--border);
    height: 60px;
    /* Fixed height */
    padding: 0 16px;
    margin: 0;
    display: flex;
    align-items: center;
    border-radius: 0;
}

/* Menubar (Below Toolbar) */
.menubar {
    display: flex;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    height: 40px;
    align-items: center;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 40;
}

.small-btn {
    height: 32px;
    font-size: 13px;
    padding: 0 12px;
}

/* Menubar Buttons - Match menu-item styling for consistency */
.menubar .btn {
    background-color: transparent !important;
    border: none;
    box-shadow: none;
    color: var(--muted-foreground);
    opacity: 1;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
}

.menubar .btn:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
    opacity: 1;
}

.menubar .btn.primary-btn {
    background-color: var(--primary) !important;
    color: var(--primary-foreground);
    opacity: 1;
}

.menubar .btn.primary-btn:hover {
    background-color: var(--primary);
    opacity: 0.9;
}

.menu-item {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted-foreground);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    user-select: none;
}

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

.menu-item.active {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

.menu-item.disabled,
.menu-item[disabled] {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Dropdowns (Popover Style) */
.menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 280px;
    background-color: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 12px;
    display: none;
    /* Hidden by default */
    z-index: 1000;
    animation: zoomIn 0.1s ease-out;
}

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

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

.menu-item.active > .menu-dropdown {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Layout Dropdown Styles */
.layout-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 4px;
}

.layout-item {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card);
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.layout-item:hover {
    background: var(--accent);
    border-color: var(--muted-foreground);
}

.layout-item.selected {
    background: var(--accent);
    border-color: var(--primary);
    color: var(--accent-foreground);
}

.layout-item .layout-icon {
    font-size: 24px;
    opacity: 0.7;
}

.layout-item .layout-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--foreground);
}

/* Resolution Panel Styles */
.resolution-categories {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
}

.resolution-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 13px;
    gap: 12px;
    background: var(--card);
    border: 1px solid transparent;
}

.resolution-option:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.resolution-option.selected {
    background: var(--accent);
    border-color: var(--primary);
    color: var(--accent-foreground);
}

.resolution-option .resolution-name {
    flex: 1;
    font-weight: 500;
}

.resolution-option .resolution-dimensions {
    font-size: 11px;
    opacity: 0.7;
}

/* Templates Dropdown Styles */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 4px;
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--card);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-item:hover {
    background: var(--accent);
    border-color: var(--muted-foreground);
}

.template-item.selected {
    background: var(--accent);
    border-color: var(--primary);
}

.template-item .template-preview {
    flex: 1;
    background: var(--muted);
    border-radius: 4px;
    min-height: 60px;
}

.template-item .template-name {
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    color: var(--foreground);
}

/* Dropdown Items */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--popover-foreground);
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    border-radius: 4px;
    margin-bottom: 4px;
    transition: background-color 0.2s;
}

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

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

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--muted-foreground);
}

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

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 100px);
    /* 100vh - toolbar(60) - menubar(40) */
}

/* Sidebar & Control Panels */
.control-panels,
.gallery-bar {
    background-color: var(--card);
    /* Zinc-950/Black */
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.control-panels {
    width: 320px;
    /* Shadcn standard sidebar width usually 250-320 */
    border-right: none;
    /* Right panel */
}

.gallery-bar {
    width: 320px;
    border-left: none;
    /* Left panel */
    background-color: #000000;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
    padding: 0 4px;
    flex-shrink: 0;
    position: relative;
    z-index: 20;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted-foreground);
    padding: 12px 0;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

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

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

/* Sidebar Content */
.sidebar-content,
.gallery-content-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background-color: var(--card);
    width: 100%;
    box-sizing: border-box;
}

.gallery-content-wrapper {
    background-color: #000000;
}

.gallery-content {
    gap: 8px !important;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.15s ease;
}

.tab-pane.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- Components (Shadcn Style) --- */

/* Typography */
h5,
h6,
.panel-title {
    color: var(--foreground);
    font-weight: 600;
    font-size: 0.875rem;
    /* 14px */
    letter-spacing: -0.01em;
    margin-bottom: 12px;
}

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

/* Inputs */
input[type="text"],
input[type="number"],
select,
textarea,
.input-control,
.select-control {
    background-color: transparent !important;
    border: 1px solid var(--input) !important;
    border-radius: var(--radius) !important;
    color: var(--foreground) !important;
    padding: 8px 12px !important;
    font-size: 0.875rem !important;
    /* 14px */
    transition: border-color 0.2s;
    width: 100%;
    box-shadow: none !important;
}

input:focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: var(--ring) !important;
    box-shadow: 0 0 0 1px var(--ring);
}

input::placeholder {
    color: var(--muted-foreground);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    height: 36px;
    padding: 0 16px;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid var(--border);
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    box-shadow: none !important;
}

.btn:hover {
    background-color: var(--secondary);
    opacity: 0.9;
}

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

.btn.primary-btn:hover {
    opacity: 0.9;
    background-color: var(--primary);
    /* Maintain color, opacity handles hover */
}

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

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

.btn i {
    margin-right: 8px;
}

/* Gallery Items */
.gallery-item-image {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--muted);
    transition: all 0.2s;
}

.gallery-item:hover .gallery-item-image {
    border-color: var(--muted-foreground);
}

.gallery-item.selected .gallery-item-image {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Canvas Area */
.canvas-container {
    background-color: var(--background);
    /* Same as body for seamless look */
    /* Add dot pattern or grid? Optional. Keep simple for now */
}

/* Resolution Options in Dropdown */
.resolution-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.resolution-option {
    padding: 8px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.resolution-option:hover {
    background-color: var(--accent);
}

.resolution-option.selected {
    background-color: var(--accent);
    border-color: var(--primary);
}

/* Legacy Support (Robust Collapsible) */
.settings-section .section-content {
    max-height: 5000px !important;
    opacity: 1 !important;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out;
}

.hidden-content {
    display: none !important;
}

/* Utilities */
.divider {
    height: 1px;
    background-color: var(--border);
    margin: 16px 0;
}

.full-width {
    width: 100%;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}