/* Material You Components */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--md-sys-spacing-xs);
    padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
    border: none;
    border-radius: var(--md-sys-shape-corner-large);
    font-family: 'Roboto', sans-serif;
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-sys-typescale-label-large-weight);
    line-height: var(--md-sys-typescale-label-large-line-height);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 40px;
    box-shadow: var(--md-sys-elevation-level-1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.btn:hover::before {
    opacity: 0.08;
}

.btn:active::before {
    opacity: 0.12;
}

.btn-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

.btn-primary:hover {
    box-shadow: var(--md-sys-elevation-level-2);
}

.btn-secondary {
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
}

.btn-secondary:hover {
    box-shadow: var(--md-sys-elevation-level-2);
}

.btn-danger {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
}

.btn-danger:hover {
    box-shadow: var(--md-sys-elevation-level-2);
}

.btn-icon {
    font-size: 18px;
    line-height: 1;
}

/* Button Row Layout */
.button-row {
    display: flex;
    gap: var(--md-sys-spacing-sm);
}

.button-row .btn {
    flex: 1;
}

/* Toggle Buttons */
.toggle-buttons {
    display: flex;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: var(--md-sys-shape-corner-large);
    padding: 2px;
    gap: 2px;
}

.toggle-btn {
    flex: 1;
    padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
    border: none;
    border-radius: var(--md-sys-shape-corner-medium);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    font-family: 'Roboto', sans-serif;
    font-size: var(--md-sys-typescale-label-medium-size);
    font-weight: var(--md-sys-typescale-label-medium-weight);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    min-height: 36px;
}

.toggle-btn.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    box-shadow: var(--md-sys-elevation-level-1);
}

.toggle-btn:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Ratio Buttons */
.ratio-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--md-sys-spacing-xs);
}

.ratio-btn {
    padding: var(--md-sys-spacing-sm);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: var(--md-sys-typescale-label-small-size);
    font-weight: var(--md-sys-typescale-label-small-weight);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    min-height: 32px;
}

.ratio-btn.active {
    background-color: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    border-color: var(--md-sys-color-primary);
}

.ratio-btn:hover:not(.active) {
    background-color: var(--md-sys-color-surface-variant);
    border-color: var(--md-sys-color-outline);
}

/* Inputs */
.color-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    cursor: pointer;
    transition: border-color 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.color-input:hover {
    border-color: var(--md-sys-color-outline);
}

.color-input:focus {
    border-color: var(--md-sys-color-primary);
}

.select-input {
    width: 100%;
    padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: var(--md-sys-typescale-body-medium-size);
    cursor: pointer;
    transition: border-color 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    min-height: 40px;
}

.select-input:hover {
    border-color: var(--md-sys-color-outline);
}

.select-input:focus {
    border-color: var(--md-sys-color-primary);
}

/* Sliders */
.slider-container {
    display: flex;
    align-items: center;
    gap: var(--md-sys-spacing-sm);
}

.slider {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--md-sys-color-surface-variant);
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    box-shadow: var(--md-sys-elevation-level-2);
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: var(--md-sys-elevation-level-3);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--md-sys-color-primary);
    cursor: pointer;
    border: none;
    box-shadow: var(--md-sys-elevation-level-2);
}

.slider-value {
    min-width: 40px;
    text-align: right;
    font-size: var(--md-sys-typescale-label-small-size);
    color: var(--md-sys-color-on-surface-variant);
}

/* Labels */
.control-label {
    display: block;
    font-size: var(--md-sys-typescale-label-medium-size);
    font-weight: var(--md-sys-typescale-label-medium-weight);
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: var(--md-sys-spacing-xs);
}

/* Control Groups */
.control-group {
    margin-bottom: var(--md-sys-spacing-md);
}

.gradient-inputs {
    display: flex;
    gap: var(--md-sys-spacing-sm);
}

.gradient-inputs .color-input {
    flex: 1;
}

.gradient-direction {
    margin-top: 6px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--md-sys-color-surface);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-level-4);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--md-sys-spacing-lg);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.modal-header h3 {
    font-size: var(--md-sys-typescale-headline-small-size);
    font-weight: var(--md-sys-typescale-headline-small-weight);
    color: var(--md-sys-color-on-surface);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    padding: var(--md-sys-spacing-xs);
    border-radius: var(--md-sys-shape-corner-small);
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.modal-close:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.modal-body {
    padding: var(--md-sys-spacing-lg);
}

.export-options {
    margin-bottom: var(--md-sys-spacing-lg);
}

.export-option {
    margin-bottom: var(--md-sys-spacing-md);
}

.export-actions {
    display: flex;
    gap: var(--md-sys-spacing-sm);
    justify-content: flex-end;
}

/* Shape Grid */
.shapes-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--md-sys-spacing-sm);
    max-height: 300px;
    overflow-y: auto;
    padding: var(--md-sys-spacing-sm);
}

.shape-item {
    aspect-ratio: 1;
    border: 2px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--md-sys-spacing-sm);
}

.shape-item:hover {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-surface-variant);
    transform: translateY(-2px);
    box-shadow: var(--md-sys-elevation-level-2);
}

.shape-item:active {
    cursor: grabbing;
    transform: translateY(0);
}

.shape-item svg {
    width: 100%;
    height: 100%;
    max-width: 32px;
    max-height: 32px;
}

/* Drag and Drop */
.drag-over {
    border-color: var(--md-sys-color-primary) !important;
    background-color: var(--md-sys-color-primary-container) !important;
    transform: scale(1.05) !important;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--md-sys-color-outline);
    border-top-color: var(--md-sys-color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
} 

/* Custom Color Picker */
.custom-color-button {
    display: flex;
    align-items: center;
    gap: var(--md-sys-spacing-sm);
    padding: var(--md-sys-spacing-sm);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    min-height: 40px;
}

.custom-color-button:hover {
    border-color: var(--md-sys-color-outline);
    box-shadow: var(--md-sys-elevation-level-1);
}

.custom-color-button:active {
    transform: translateY(1px);
}

.color-preview {
    width: 24px;
    height: 24px;
    border-radius: var(--md-sys-shape-corner-small);
    border: 2px solid var(--md-sys-color-outline-variant);
    flex-shrink: 0;
}

.custom-color-picker {
    display: none;
    width: 280px;
    background-color: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-level-3);
    overflow: hidden;
    margin-top: var(--md-sys-spacing-xs);
}

.custom-color-picker.active {
    display: block;
}

.color-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--md-sys-spacing-md);
    background-color: var(--md-sys-color-surface-variant);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.color-picker-title {
    font-size: var(--md-sys-typescale-label-large-size);
    font-weight: var(--md-sys-typescale-label-large-weight);
    color: var(--md-sys-color-on-surface-variant);
}

.color-picker-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.color-picker-close:hover {
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
}

.color-picker-content {
    padding: var(--md-sys-spacing-md);
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--md-sys-spacing-xs);
    margin-bottom: var(--md-sys-spacing-md);
}

.preset-color {
    width: 32px;
    height: 32px;
    border-radius: var(--md-sys-shape-corner-small);
    border: 2px solid var(--md-sys-color-outline-variant);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    position: relative;
}

.preset-color:hover {
    transform: scale(1.1);
    border-color: var(--md-sys-color-primary);
    box-shadow: var(--md-sys-elevation-level-2);
}

.preset-color:active {
    transform: scale(0.95);
}

.color-input-section {
    margin-top: var(--md-sys-spacing-md);
}

.color-input-label {
    display: block;
    font-size: var(--md-sys-typescale-label-medium-size);
    font-weight: var(--md-sys-typescale-label-medium-weight);
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: var(--md-sys-spacing-xs);
}

.color-input-wrapper {
    display: flex;
    gap: var(--md-sys-spacing-xs);
}

.color-hex-input {
    flex: 1;
    padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-family: 'Roboto', sans-serif;
    font-size: var(--md-sys-typescale-body-medium-size);
    transition: border-color 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.color-hex-input:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
}

.color-native-input {
    width: 48px;
    height: 40px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    background: transparent;
    cursor: pointer;
    transition: border-color 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.color-native-input:hover {
    border-color: var(--md-sys-color-outline);
}

.color-native-input:focus {
    border-color: var(--md-sys-color-primary);
}

/* Hide the default color input styling */
.color-native-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-native-input::-webkit-color-swatch {
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
}

.color-native-input::-moz-color-swatch {
    border: none;
    border-radius: var(--md-sys-shape-corner-small);
}

/* Custom Color Palette */
.color-palette-controls { display: flex; flex-direction: column; gap: 10px; }

.palette-colors { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 160px; overflow-y: auto; padding-right: 4px; overflow-x: hidden; }

.palette-color-slot { position: relative; width: 100%; height: 48px; border: 2px dashed var(--md-sys-color-outline-variant); border-radius: var(--md-sys-shape-corner-small); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1); background-color: var(--md-sys-color-surface); }

.palette-color-slot:hover {
    border-color: var(--md-sys-color-outline);
    background-color: var(--md-sys-color-surface-variant);
}

.palette-color-slot.has-color {
    border-style: solid;
    border-color: var(--md-sys-color-outline);
}

.palette-color-slot .color-preview { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--md-sys-color-outline-variant); background-color: transparent; }

.palette-color-slot.has-color .color-preview {
    background-color: var(--color-value);
}

.palette-color-slot .material-icons {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 24px;
}

.palette-color-slot.has-color .material-icons {
    display: none;
}

.palette-color-slot.active {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.image-upload-section {
    display: flex;
    flex-direction: column;
    gap: var(--md-sys-spacing-sm);
    overflow: visible;
}

/* Reduce vertical footprint of palette section */
.color-palette-controls .upload-hint { display: none; }

.upload-area {
    border: 2px dashed var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-small);
    padding: var(--md-sys-spacing-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    background-color: var(--md-sys-color-surface);
}

.upload-area:hover {
    border-color: var(--md-sys-color-outline);
    background-color: var(--md-sys-color-surface-variant);
}

.upload-area.dragover {
    border-color: var(--md-sys-color-primary);
    background-color: var(--md-sys-color-primary-container);
}

.upload-content { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--md-sys-color-on-surface-variant); }

.upload-content .material-icons { font-size: 28px; }

.upload-hint {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
    margin: 0;
}

/* Small helper text for panels */
.panel-hint {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: var(--md-sys-spacing-sm);
}

/* Progress Bar */
.export-progress {
    margin: var(--md-sys-spacing-md) 0;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: var(--md-sys-spacing-sm);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--md-sys-color-surface-variant);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--md-sys-color-primary), var(--md-sys-color-expressive-primary));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.progress-text {
    text-align: center;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
    font-weight: 500;
}

/* Layers */
.layers-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.layer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 8px;
    background: var(--md-sys-color-surface);
    cursor: grab;
}
.layer-name { color: var(--md-sys-color-on-surface); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item.dragging { opacity: 0.6; }
.layer-item.selected { border-color: var(--md-sys-color-primary); }

/* Context Menu */
.shape-context-menu {
    position: fixed;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-level-3);
    z-index: 1000;
    min-width: 160px;
    padding: 8px 0;
    animation: contextMenuFadeIn 0.15s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: var(--md-sys-spacing-sm);
    padding: var(--md-sys-spacing-sm) var(--md-sys-spacing-md);
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    font-size: var(--md-sys-typescale-label-medium-size);
    font-weight: var(--md-sys-typescale-label-medium-weight);
    transition: background-color 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    user-select: none;
}

.context-menu-item:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.context-menu-item:active {
    background-color: var(--md-sys-color-surface-variant);
}

.context-menu-item.disabled {
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.5;
    cursor: not-allowed;
}

.context-menu-item.disabled:hover {
    background-color: transparent;
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
} 