/**
 * Designer Module - Modern Layout
 * Main Layout and Structure
 *
 * @package    Designer Module
 * @subpackage CSS
 * @author     Kilo Code AI
 * @version    2.0.0
 */

/* ===== MAIN CONTAINER ===== */

.designer-modern {
    display: flex;
    flex-direction: column;
    /*height: 100vh;*/
    background: var(--bg-secondary);
    overflow: hidden;
    font-family: var(--font-primary);
}

/* Backward compatibility - hide old container */
.designer-container {
    display: none;
}

/* ===== HEADER (TOP BAR) ===== */

.designer-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    z-index: var(--z-fixed);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ===== MAIN CONTENT AREA ===== */

.designer-main {
    display: flex;
    margin-top: 64px;
    /*height: calc(100vh - 64px);*/
    overflow: hidden;
}

/* ===== LEFT TOOLBAR (EXPANDABLE) ===== */

.designer-toolbar {
    width: 64px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-4) 0;
    gap: var(--space-2);
    overflow: hidden;
    flex-shrink: 0;
    transition: width var(--transition-base);
}

.designer-toolbar.expanded {
    width: 200px;
}

.toolbar-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    flex-shrink: 0;
    padding: 0 var(--space-3);
    margin: 0 var(--space-2);
    white-space: nowrap;
}

.designer-toolbar.expanded .toolbar-btn {
    width: calc(100% - var(--space-4));
    justify-content: flex-start;
}

.toolbar-label {
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
}

.designer-toolbar.expanded .toolbar-label {
    opacity: 1;
    visibility: visible;
}

.toolbar-toggle {
    margin-bottom: var(--space-2);
}

.toolbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toolbar-btn.active {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
}

.toolbar-btn.btn-danger:hover {
    background: var(--accent-danger-light);
    color: var(--accent-danger);
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.toolbar-divider {
    width: 32px;
    height: 1px;
    background: var(--border-light);
    margin: var(--space-2) 0;
    flex-shrink: 0;
}

/* Tooltip for Toolbar */
.toolbar-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    background: var(--text-primary);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
    z-index: var(--z-tooltip);
}

.toolbar-btn:hover[data-tooltip]::after {
    opacity: 1;
}

/* Hide tooltip when toolbar is expanded */
.designer-toolbar.expanded .toolbar-btn[data-tooltip]::after {
    display: none;
}

/* Toolbar button icon alignment */
.toolbar-btn i {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* ===== CANVAS AREA (CENTER) ===== */

.designer-canvas-area {
       flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-8);
    position: relative;
    overflow: auto;
    background: var(--bg-secondary);
    padding-top: 8em;
}

/* Zoom Toolbar */
.zoom-toolbar {
    position: absolute;
    top: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.zoom-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.zoom-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.zoom-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.zoom-display,
.zoom-level-display {
    min-width: 60px;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--accent-primary);
    padding: 0 var(--space-2);
}

/* Canvas Wrapper */
.canvas-wrapper {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    position: relative;
}

#designer-canvas {
    display: block;
}

/* Object Info (Floating) */
.object-info {
    position: absolute;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: var(--space-6);
    animation: slideUp 0.3s ease-out;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.info-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: var(--font-medium);
}

.info-value {
    font-size: var(--text-sm);
    color: var(--text-primary);
    font-weight: var(--font-semibold);
}

/* ===== RIGHT PANEL ===== */

.designer-panel {
    width: 320px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: visible;
    transition: width var(--transition-slow), transform var(--transition-slow);
    flex-shrink: 0;
}

.designer-panel.collapsed {
    width: 0;
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.panel-header h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.panel-section {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.panel-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Preview Section */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.preview-item {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    transition: all var(--transition-base);
}

.preview-item:hover {
    box-shadow: var(--shadow-sm);
}

.preview-label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.preview-image {
    min-height: 120px;
    background: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
}

.preview-image img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
}

.preview-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

/* Layers Section */
.layer-search {
    margin-bottom: var(--space-4);
}

.layer-search input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    transition: all var(--transition-base);
}

.layer-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-accent);
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 400px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
}

.layer-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.layer-item.active {
    background: var(--accent-primary-light);
    border-color: var(--accent-primary);
}

.layer-item.hidden {
    opacity: 0.5;
}

.layer-item.locked {
    background: var(--bg-tertiary);
    cursor: not-allowed;
}

.layer-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.layer-icon.type-text {
    background: var(--accent-success);
}

.layer-name {
    flex: 1;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-name[contenteditable="true"] {
    outline: 2px solid var(--accent-primary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: white;
}

.layer-controls {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.layer-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
}

.layer-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.layer-btn.active {
    background: var(--accent-primary-light);
    color: var(--accent-primary);
}

.layer-btn.layer-delete:hover {
    background: var(--accent-danger-light);
    color: var(--accent-danger);
}

.layer-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.layers-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--text-tertiary);
}

.layers-empty i {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.layers-empty p {
    font-size: var(--text-sm);
    margin: 0;
}

/* Shortcuts Section */
.shortcuts-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.shortcut-item kbd {
    margin-left: var(--space-2);
}

/* Collapsible Section */
.panel-section.collapsible .section-title {
    cursor: pointer;
    user-select: none;
}

.panel-section.collapsible .section-title i {
    transition: transform var(--transition-base);
}

.panel-section.collapsible.collapsed .section-title i {
    transform: rotate(-90deg);
}

.panel-section.collapsible.collapsed .shortcuts-content {
    display: none;
}

/* ===== PROPERTIES PANEL (BOTTOM) ===== */

.properties-panel {
    position: fixed;
    bottom: 0;
    left: 64px;
    right: 320px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-sticky) + 1);
    animation: slideUp 0.3s ease-out;
    transition: left var(--transition-base);
}

/* Adjust when toolbar is expanded */
body:has(.designer-toolbar.expanded) .properties-panel {
    left: 200px;
}

.properties-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
}

.properties-header h4 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
}

.properties-body {
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-height: 240px;
    overflow-y: auto;
}

.property-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-4);
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.property-group label {
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
}

/* ===== SURFACE SELECTOR ===== */

.surface-selector {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
}

.surface-selector h3 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.surface-btn {
    width: 100%;
    margin-bottom: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    text-align: left;
}

.surface-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-medium);
}

.surface-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ===== TEXT CONTROLS ===== */

.text-controls,
.image-controls {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
    display: none;
}

.text-controls h3,
.image-controls h3 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.text-controls label,
.image-controls label {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
}

.text-controls input[type="text"],
.text-controls input[type="number"],
.text-controls input[type="color"],
.text-controls select,
.image-controls select,
.image-controls input[type="range"] {
    width: 100%;
    margin-bottom: var(--space-3);
}

.text-controls .checkbox-group {
    margin-bottom: var(--space-3);
}

.text-controls .checkbox-group label {
    display: inline-flex;
    align-items: center;
    margin-right: var(--space-4);
    margin-bottom: var(--space-2);
    font-weight: normal;
    cursor: pointer;
}

.text-controls .checkbox-group input[type="checkbox"] {
    margin-right: var(--space-2);
    width: auto;
}

/* ===== DESIGNER ACTIONS ===== */

.designer-actions {
    margin-top: var(--space-6);
    display: flex;
    gap: var(--space-4);
    justify-content: center;
}

/* ===== DESIGNER ALERT ===== */

.designer-alert {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid;
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}

.designer-alert-info {
    background: var(--accent-primary-light);
    border-color: var(--accent-primary);
    color: var(--accent-primary-dark);
}

.designer-alert-success {
    background: var(--accent-success-light);
    border-color: var(--accent-success);
    color: #065F46;
}

.designer-alert-warning {
    background: var(--accent-warning-light);
    border-color: var(--accent-warning);
    color: #92400E;
}

.designer-alert-error {
    background: var(--accent-danger-light);
    border-color: var(--accent-danger);
    color: #991B1B;
}

/* ===== UTILITY CLASSES ===== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-10 {
    margin-top: var(--space-3);
}

.mt-20 {
    margin-top: var(--space-6);
}

.mb-10 {
    margin-bottom: var(--space-3);
}

.mb-20 {
    margin-bottom: var(--space-6);
}

/* ===== BACKWARD COMPATIBILITY ===== */

/* Old sidebar classes - hide them */
.designer-sidebar,
.designer-preview,
.tool-section,
.align-buttons-row {
    display: none !important;
}

/* Ensure modern layout is visible */
.designer-modern {
    display: flex !important;
}

/* ===== ADDITIONAL PANEL STYLES ===== */

/* Panel scrollbar styling removed - panels use overflow: visible */

/* ===== ZOOM HINT ===== */

.zoom-hint {
    margin-left: auto;
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.zoom-hint i {
    color: var(--accent-primary);
}

/* ===== PROPERTIES CONTENT ===== */

.properties-content {
    width: 100%;
}

/* ===== LAYER NAME TEXT ===== */

.layer-name-text {
    display: inline-block;
}

.layer-name-input {
    width: 100%;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: var(--font-primary);
}

/* ===== LAYER VISIBILITY STATES ===== */

.layer-visibility.active i::before {
    content: "\f06e"; /* fa-eye */
}

.layer-visibility:not(.active) i::before {
    content: "\f070"; /* fa-eye-slash */
}

.layer-lock.active i::before {
    content: "\f023"; /* fa-lock */
}

.layer-lock:not(.active) i::before {
    content: "\f09c"; /* fa-unlock */
}

/* ===== LAYERS PANEL (BOTTOM POPUP) ===== */

.layers-panel {
    position: fixed;
    bottom: 0;
    left: 64px;
    right: 320px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-sticky);
    animation: slideUp 0.3s ease-out;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    transition: left var(--transition-base);
}

/* Adjust when toolbar is expanded */
body:has(.designer-toolbar.expanded) .layers-panel {
    left: 200px;
}

.layers-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.layers-panel-header h4 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.layers-panel-body {
    padding: var(--space-6);
    overflow-y: auto;
    flex: 1;
}

/* Adjust properties panel when layers panel is open */
.properties-panel {
    transition: bottom var(--transition-base);
}

.layers-panel:not([style*="display: none"]) ~ .properties-panel {
    bottom: 400px;
}
