/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #374151;
    --secondary-hover: #4b5563;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #252542;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border-color: #374151;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* Layout */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    height: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.app-main {
    display: flex;
    height: calc(100vh - 60px - 40px);
    margin-top: 60px;
}

.app-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 1.5rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.app-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-section h2 span {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

/* Upload Buttons */
.upload-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.upload-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.upload-btn svg {
    flex-shrink: 0;
}

/* Settings */
.settings-group {
    margin-bottom: 1rem;
}

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

.settings-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.settings-group input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.settings-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker-wrapper input[type="color"] {
    width: 40px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: none;
}

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

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

.color-value {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-family: monospace;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    transition: var(--transition);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

/* Elements List */
.elements-list {
    flex: 1;
    overflow-y: auto;
}

.elements-container {
    max-height: 300px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 1.5rem 1rem;
}

.element-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.element-item:hover {
    background: var(--bg-card-hover);
}

.element-item.active {
    background: var(--primary-color);
}

.element-thumbnail {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-card);
}

.element-info {
    flex: 1;
    overflow: hidden;
}

.element-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.element-type {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Board Container */
.board-container {
    flex: 1;
    overflow: auto;
    background: var(--bg-dark);
    position: relative;
}

.mood-board {
    width: 100%;
    height: 100%;
    min-width: 1200px;
    min-height: 800px;
    position: relative;
    background-color: #1a1a2e;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 24px 24px;
}

.board-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    pointer-events: none;
}

.board-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.board-placeholder p {
    font-size: 1rem;
}

/* Board Elements */
.board-element {
    position: absolute;
    cursor: move;
    user-select: none;
    transition: box-shadow 0.2s ease;
}

.board-element:hover {
    z-index: 10;
}

.board-element.selected {
    z-index: 20;
}

.board-element.selected::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--primary-color);
    border-radius: inherit;
    pointer-events: none;
}

.board-element .resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.board-element.selected .resize-handle {
    opacity: 1;
}

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

/* Image Element */
.image-element {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-card);
}

.image-element img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-element.style-rounded {
    border-radius: var(--radius-lg);
}

.image-element.style-circle {
    border-radius: 50%;
}

.image-element.style-shadow {
    box-shadow: var(--shadow-lg);
}

/* Audio Element */
.audio-element {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
    border-radius: var(--radius-md);
    padding: 1rem;
    min-width: 200px;
    border: 1px solid var(--border-color);
}

.audio-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.audio-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.audio-info {
    flex: 1;
    overflow: hidden;
}

.audio-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.audio-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-color);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.play-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: var(--bg-dark);
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
}

.audio-progress-fill {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.1s linear;
}

.audio-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 35px;
    text-align: right;
}

/* Text Element */
.text-element {
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-width: 150px;
    max-width: 400px;
}

.text-content {
    font-size: 1rem;
    color: var(--text-primary);
    word-wrap: break-word;
    outline: none;
}

.text-content:empty::before {
    content: 'Click to edit...';
    color: var(--text-muted);
}

/* Description tooltip */
.element-description {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 8px;
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.board-element:hover .element-description {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

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

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

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

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

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

/* Modals */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-dark);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

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

.form-group {
    margin-bottom: 1.25rem;
}

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

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

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.size-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.size-inputs input {
    width: 80px;
}

.size-inputs span {
    color: var(--text-muted);
}

.aspect-ratio-lock {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.aspect-ratio-lock input {
    display: none;
}

.aspect-ratio-lock:has(input:checked) {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.style-options {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.style-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

.style-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.style-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Share Modal */
.share-info {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.share-link-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.share-link-container input {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: monospace;
}

.share-options h4 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.export-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 60px;
    right: 1rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    max-width: 350px;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
}

.toast.info {
    border-left: 4px solid var(--primary-color);
}

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

/* Drag and Drop */
.mood-board.drag-over {
    background-color: rgba(99, 102, 241, 0.1);
}

.mood-board.drag-over::after {
    content: 'Drop files here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: var(--primary-color);
    pointer-events: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0.5rem 1rem;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .header-actions .btn span {
        display: none;
    }

    .header-actions .btn {
        padding: 0.5rem;
    }

    .app-main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-section {
        min-width: 200px;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
    }

    .upload-buttons {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .upload-btn {
        flex-direction: column;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .board-container {
        height: calc(100vh - 60px - 200px - 40px);
    }

    .mood-board {
        min-width: 100%;
        min-height: 100%;
    }

    .elements-list {
        display: none;
    }

    .modal-content {
        max-height: 80vh;
    }

    .export-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-height: 150px;
    }

    .sidebar-section {
        min-width: 150px;
        padding: 0.75rem;
    }

    .sidebar-section h2 {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .board-container {
        height: calc(100vh - 60px - 150px - 40px);
    }
}

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

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

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

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

/* Focus visible */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: var(--primary-color);
    color: white;
}
