/* DesignFlow Editor - Styles */

:root {
    --primary: #7C3AED;
    --primary-hover: #6D28D9;
    --secondary: #1E1E2E;
    --surface: #2D2D3F;
    --surface-hover: #3D3D5C;
    --border: #3D3D5C;
    --text: #FFFFFF;
    --text-secondary: #A0A0B0;
    --accent: #22D3EE;
    --danger: #EF4444;
    --success: #22C55E;
    --canvas-bg: #FFFFFF;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--secondary);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

/* Header */
.header {
    height: 50px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 20px;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface-hover);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.file-name:hover {
    background: var(--border);
}

.file-name i {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 8px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger);
    color: var(--text);
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-block {
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--surface-hover);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-icon:hover,
.btn-icon.active {
    background: var(--primary);
}

.btn-group {
    display: flex;
    gap: 4px;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 50px);
}

/* Left Sidebar - Tools */
.sidebar-left {
    width: 60px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;           /* allow scrolling when there are many tools */
    max-height: calc(100vh - 50px); /* header height excluded */
}


.tool-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.tool-group.bottom {
    margin-top: auto;
    margin-bottom: 0;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: var(--transition);
}

.tool-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tool-btn.active {
    background: var(--primary);
    color: var(--text);
}

.zoom-level {
    font-size: 11px;
    text-align: center;
    color: var(--text-secondary);
    padding: 4px 0;
}

/* Pages Panel */
.pages-panel {
    border-top: 1px solid var(--border);
    padding: 8px 0;
    margin-top: 16px;
}

.pages-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    margin-bottom: 8px;
}

.pages-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.pages-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 4px;
}

.page-item {
    padding: 8px 8px;
    border-radius: 6px;
    background: var(--surface-hover);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

.page-item:hover {
    background: var(--border);
    color: var(--text);
}

.page-item.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--text);
    font-weight: 600;
}

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

.page-item-delete {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 10px;
    padding: 0 4px;
    opacity: 0;
    transition: var(--transition);
}

.page-item:hover .page-item-delete {
    opacity: 1;
}

.page-item-delete:hover {
    color: var(--danger);
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    background: #151520;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.canvas-wrapper {
    position: relative;
    box-shadow: var(--shadow);
    touch-action: none;
}

.canvas {
    background: var(--canvas-bg);
    position: relative;
    overflow: hidden;
    touch-action: none;
}

.canvas.select-mode {
    cursor: default;
}

.canvas.select-mode:hover {
    cursor: crosshair;
}

/* Canvas Elements */
.canvas-element {
    position: absolute;
    cursor: move;
    user-select: none;
    min-width: 20px;
    min-height: 20px;
}

.canvas-element.selected {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.canvas-element.text-element {
    padding: 4px 8px;
    min-width: 50px;
    min-height: 24px;
}

.canvas-element.text-element[contenteditable="true"] {
    outline: 2px solid var(--accent);
    cursor: text;
}

.canvas-element.shape-element {
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-element.shape-element.rectangle {
    border-radius: 0;
}

.canvas-element.shape-element.circle {
    border-radius: 50%;
}

.canvas-element.shape-element.line,
.canvas-element.shape-element.arrow {
    background: transparent !important;
}

.canvas-element.shape-element.line::before,
.canvas-element.shape-element.arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: currentColor;
}

.canvas-element.shape-element.arrow::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: currentColor;
}

.canvas-element.image-element {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.canvas-element.image-element img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Resize Handles */
.resize-handles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--text);
    border: 2px solid var(--primary);
    border-radius: 2px;
    pointer-events: auto;
}

.resize-handle.nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle.n { top: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.resize-handle.ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.e { top: 50%; margin-top: -5px; right: -5px; cursor: ew-resize; }
.resize-handle.se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resize-handle.s { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.resize-handle.sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.w { top: 50%; margin-top: -5px; left: -5px; cursor: ew-resize; }

/* Rotation Handle */
.rotation-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 50%;
    cursor: grab;
    pointer-events: auto;
}

.rotation-handle::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 14px;
    background: var(--accent);
}

/* Right Sidebar - Properties */
.sidebar-right {
    width: 280px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
}

.panel {
    border-bottom: 1px solid var(--border);
}

.panel-header {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--surface-hover);
}

.panel-content {
    padding: 12px 16px;
}

.form-group {
    margin-bottom: 12px;
}

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

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--surface-hover);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border);
    border-radius: 6px;
}

.color-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-input input[type="text"] {
    flex: 1;
    font-family: monospace;
}

/* Layer List */
.layer-list {
    max-height: 200px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--surface-hover);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.layer-item:hover {
    background: var(--border);
}

.layer-item.selected {
    background: var(--primary);
}

.layer-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.layer-name {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-visibility {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
}

.layer-visibility:hover {
    background: var(--surface);
}

.layer-visibility.hidden {
    opacity: 0.5;
}

.layer-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.layer-actions .btn-icon {
    flex: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 400px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.close-modal {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    border-radius: 6px;
}

.close-modal:hover {
    background: var(--surface-hover);
}

.modal-body {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.sticker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.sticker-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: var(--surface-hover);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.sticker-item:hover {
    background: var(--primary);
    transform: scale(1.1);
}

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

::-webkit-scrollbar-track {
    background: var(--surface);
}

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

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

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

.canvas-element {
    animation: fadeIn 0.2s ease;
}

/* Responsive Design */

/* Tablet - Medium screens (768px to 1024px) */
@media (max-width: 1024px) {
    .sidebar-right {
        width: 240px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .header-left {
        gap: 16px;
    }
    
    .logo {
        font-size: 14px;
    }
}

/* Mobile - Small screens (max 768px) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    /* Header adjustments */
    .header {
        height: 50px;
        padding: 0 8px;
    }
    
    .header-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }
    
    .logo span {
        display: none;
    }
    
    .file-name {
        display: none;
    }
    
    .header-right {
        gap: 4px;
    }
    
    .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .btn i {
        margin-right: 0;
    }
    
    /* Sidebars */
    .sidebar-left {
        width: 50px;
        padding: 8px;
    }
    
    .sidebar-right {
        width: 200px;
    }
    
    .tool-group {
        gap: 2px;
        margin-bottom: 12px;
    }
    
    .tool-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .zoom-level {
        font-size: 10px;
    }
    
    /* Pages panel */
    .pages-panel {
        max-height: 120px;
    }
    
    .pages-header {
        padding: 0 6px;
    }
    
    .pages-title {
        font-size: 9px;
    }
    
    .pages-list {
        max-height: 80px;
        padding: 0 2px;
    }
    
    .page-item {
        padding: 6px;
        font-size: 11px;
    }
    
    /* Canvas */
    .canvas-area {
        margin: 0 auto;
    }
    
    .canvas {
        max-width: calc(100vw - 50px);
    }
    
    /* Properties panel improvements */
    .panel-header {
        padding: 10px 12px;
        font-size: 11px;
    }
    
    .panel-content {
        padding: 10px 12px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    .form-group label {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    input[type="text"],
    input[type="number"],
    select {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .resize-handle {
        width: 8px;
        height: 8px;
    }
    
    .rotation-handle {
        width: 14px;
        height: 14px;
        top: -28px;
    }
    
    .rotation-handle::before {
        height: 12px;
    }
    
    /* Modal adjustments */
    .modal {
        max-height: 80vh;
        width: 90vw !important;
    }
}

/* Extra small screens (max 480px) */
@media (max-width: 480px) {
    .header {
        height: 45px;
        padding: 0 4px;
    }
    
    .logo i {
        font-size: 16px;
    }
    
    .sidebar-left {
        width: 45px;
        padding: 6px;
    }
    
    .tool-btn {
        width: 30px;
        height: 30px;
        font-size: 13px;
    }
    
    .sidebar-right {
        width: 100%;
        max-width: 100%;
    }
    
    .canvas {
        max-width: calc(100vw - 45px);
    }
    
    .btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .main-container {
        height: calc(100vh - 45px);
    }
}

