/* ============================================
   DOM-Based Visual Design Editor - Styles
   ============================================ */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    overflow: hidden;
    height: 100vh;
}

/* ============================================
   Toolbar Styles
   ============================================ */

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background-color: #16213e;
    border-bottom: 1px solid #0f3460;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-right: 1px solid #0f3460;
}

.toolbar-group:last-child {
    border-right: none;
}

/* Button Styles */
.btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background-color: #1a1a2e;
    color: #eee;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background-color: #0f3460;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    background-color: #1a1a2e;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

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

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

.btn-danger {
    background-color: #e94560;
    border-color: #e94560;
}

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

.icon {
    font-size: 14px;
}

.zoom-level {
    font-size: 12px;
    color: #aaa;
    min-width: 45px;
    text-align: center;
}

/* ============================================
   Editor Container Layout
   ============================================ */

.editor-container {
    display: flex;
    height: calc(100vh - 60px);
}

/* ============================================
   Panel Styles
   ============================================ */

.panel {
    background-color: #16213e;
    border: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
}

.panel-section {
    border-bottom: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

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

.panel-header {
    padding: 12px 15px;
    background-color: #0f3460;
    border-bottom: 1px solid #1a1a2e;
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #eee;
}

.panel-body {
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
}

/* Left Panel - Layers */
.layers-panel {
    width: 220px;
    border-right: 1px solid #0f3460;
    flex-shrink: 0;
    max-height: calc(100vh - 60px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Layers panel body - takes remaining space */
.layers-panel > .panel-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
}

/* Right Panel - Properties */
.properties-panel {
    width: 280px;
    border-left: 1px solid #0f3460;
    flex-shrink: 0;
    max-height: calc(100vh - 60px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Layers Panel Styles
   ============================================ */

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background-color: #1a1a2e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.layer-item:hover {
    background-color: #0f3460;
    border-color: #e94560;
}

.layer-item.selected {
    background-color: #0f3460;
    border-color: #e94560;
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.3);
}

.layer-item .layer-icon {
    font-size: 12px;
    color: #aaa;
}

.layer-item .layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.layer-item .layer-controls {
    display: flex;
    gap: 4px;
}

.layer-item .btn-layer {
    padding: 2px 6px;
    font-size: 10px;
    background-color: #0f3460;
    border: none;
    border-radius: 4px;
    color: #aaa;
    cursor: pointer;
}

.layer-item .btn-layer:hover {
    color: #eee;
    background-color: #e94560;
}

/* ============================================
   Canvas Area Styles
   ============================================ */

.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #0f0f1a;
    overflow: hidden;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ============================================
   Canvas Styles
   ============================================ */

.canvas {
    flex: 1;
    position: relative;
    background-color: #ffffff;
    overflow: hidden;
    cursor: crosshair;
}

/* Grid Overlay */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, #f0f0f0 1px, transparent 1px),
        linear-gradient(to bottom, #f0f0f0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ============================================
   Element Styles
   ============================================ */

.element {
    position: absolute;
    cursor: move;
    user-select: none;
    overflow: visible;
}

.element.rectangle {
    background-color: #3498db;
}

.element.text {
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    min-height: 30px;
}

.element.text .text-content {
    white-space: nowrap;
    overflow: visible;
    pointer-events: none;
}

/* Selected Element */
.element.selected {
    outline: 2px solid #e94560;
    outline-offset: -1px;
}

/* Locked Element */
.element.locked {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #e94560;
    border: 2px solid #fff;
    border-radius: 2px;
    cursor: pointer;
    display: none;
}

.element.selected .resize-handle {
    display: block;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nw-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: ne-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: se-resize; }

/* Rotation Handle */
.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background-color: #e94560;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    display: none;
}

.rotate-handle::after {
    content: '↻';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: #fff;
}

.element.selected .rotate-handle {
    display: block;
}

/* ============================================
   Multi-Selection Box
   ============================================ */

.selection-box {
    position: absolute;
    border: 1px dashed #e94560;
    background-color: rgba(233, 69, 96, 0.1);
    pointer-events: none;
    z-index: 10000;
}

/* ============================================
   Smart Guides
   ============================================ */

.smart-guide {
    position: absolute;
    background-color: #e94560;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.smart-guide.vertical {
    width: 1px;
    top: 0;
    bottom: 0;
}

.smart-guide.horizontal {
    height: 1px;
    left: 0;
    right: 0;
}

/* ============================================
   Alignment Tools
   ============================================ */

.alignment-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alignment-row {
    display: flex;
    gap: 4px;
}

.btn-alignment {
    flex: 1;
    padding: 8px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background-color: #1a1a2e;
    color: #eee;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
}

.btn-alignment:hover:not(:disabled) {
    background-color: #0f3460;
    border-color: #e94560;
}

.btn-alignment:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================
   Properties Panel Styles
   ============================================ */

/* Alignment section - fixed height */
.properties-panel > .panel-section:first-child {
    flex: 0 0 auto;
    max-height: 200px;
}

/* Properties section - takes remaining space */
.properties-panel > .panel-section:nth-of-type(2) {
    flex: 1 1 auto;
    min-height: 0;
}

/* Canvas Settings section - fixed height */
.properties-panel > .panel-section:last-child {
    flex: 0 0 auto;
    max-height: 200px;
}

.no-selection {
    text-align: center;
    color: #aaa;
    padding: 40px 20px;
    font-size: 14px;
}

.property-group {
    margin-bottom: 16px;
}

.property-group:last-child {
    margin-bottom: 0;
}

.property-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #ccc;
}

.property-group input[type="text"],
.property-group input[type="number"],
.property-group input[type="color"],
.property-group textarea,
.property-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background-color: #1a1a2e;
    color: #eee;
    font-size: 13px;
    font-family: inherit;
}

.property-group input[type="text"]:focus,
.property-group input[type="number"]:focus,
.property-group input[type="color"]:focus,
.property-group textarea:focus,
.property-group select:focus {
    outline: none;
    border-color: #e94560;
}

.property-group input[type="range"] {
    width: 100%;
    accent-color: #e94560;
}

.property-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.property-row > div {
    flex: 1;
}

.property-row label {
    margin-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: #e94560;
}

.property-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* ============================================
   Ruler Styles
   ============================================ */

.ruler {
    background-color: #0f3460;
    overflow: hidden;
}

.ruler canvas {
    display: block;
}

.ruler-horizontal {
    height: 25px;
    width: 100%;
    border-bottom: 1px solid #1a1a2e;
}

.ruler-vertical {
    width: 25px;
    height: 100%;
    border-right: 1px solid #1a1a2e;
}

/* ============================================
   Auto-Save Indicator
   ============================================ */

.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    background-color: #16213e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    font-size: 12px;
    color: #aaa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    transition: all 0.3s ease;
}

.auto-save-indicator.saving {
    color: #e94560;
}

#saveStatus {
    display: flex;
    align-items: center;
    gap: 6px;
}

#saveStatus::before {
    content: '●';
    font-size: 8px;
    color: #4ade80;
}

.auto-save-indicator.saving #saveStatus::before {
    color: #e94560;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Scrollbar Styles
   ============================================ */

/* WebKit browsers (Chrome, Safari, Edge) */
.panel-body::-webkit-scrollbar,
.layers-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.panel-body::-webkit-scrollbar-track,
.layers-list::-webkit-scrollbar-track {
    background-color: #1a1a2e;
    border-radius: 4px;
}

.panel-body::-webkit-scrollbar-thumb,
.layers-list::-webkit-scrollbar-thumb {
    background-color: #0f3460;
    border-radius: 4px;
    border: 1px solid #1a1a2e;
}

.panel-body::-webkit-scrollbar-thumb:hover,
.layers-list::-webkit-scrollbar-thumb:hover {
    background-color: #e94560;
    border-color: #1a1a2e;
}

/* Firefox */
.panel-body,
.layers-list {
    scrollbar-width: thin;
    scrollbar-color: #0f3460 #1a1a2e;
}

.panel-body:hover,
.layers-list:hover {
    scrollbar-color: #e94560 #1a1a2e;
}

/* ============================================
   Responsive Styles
   ============================================ */

@media (max-width: 1200px) {
    .layers-panel,
    .properties-panel {
        width: 200px;
    }

    .toolbar-group {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .toolbar {
        padding: 8px;
        gap: 4px;
    }

    .toolbar-group {
        padding: 0 4px;
    }

    .btn {
        padding: 6px 8px;
        font-size: 12px;
    }

    .layers-panel,
    .properties-panel {
        width: 180px;
    }

    .panel-body {
        padding: 10px;
    }
}
