/* Tilpas Modal - Image Adjustment Modal
 * Extends the shared .modal-overlay + .modal-content pattern
 */

/* High z-index for tilpas modal to appear above other elements */
.modal-overlay.tilpas-overlay {
    z-index: 10000;
}

/* Modal specific sizing and layout */
.modal-content.tilpas-modal {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

/* Modal Header - teal branded like photo-modal */
.tilpas-modal .modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--neutral-200, #eee);
    flex-shrink: 0;
    background: white;
    margin-bottom: 0;
}

.tilpas-modal .modal-header h3 {
    margin: 0;
    color: var(--primary, #2B8C91);
    font-family: var(--font-brand, 'Puur', sans-serif);
    font-size: 1.3rem;
}

/* Override close button positioning for tilpas modal header */
.tilpas-modal .modal-header .btn-close-circle {
    position: static;
    margin-left: auto;
}

/* Body layout - two columns on wider screens */
.tilpas-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 24px;
    overflow-y: auto;
    gap: 24px;
    background: var(--surface-subtle, #fcfcfc);
}

/* Sections */
.tilpas-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tilpas-section.disabled {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.5);
}

.tilpas-label {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--neutral-400, #999);
}

/* Source image wrapper */
.tilpas-source-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
    background: var(--neutral-100, #f0f0f0);
    border: 1px solid var(--neutral-200, #ddd);
}

.tilpas-source-img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 300px;
    pointer-events: none;
    user-select: none;
}

/* Live preview container */
.tilpas-preview-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: var(--radius-md, 12px);
    background: var(--neutral-100, #f0f0f0);
    border: 2px solid var(--brand-primary, #2B8C91);
    box-shadow: var(--shadow-sm);
}

.tilpas-preview-container img {
    position: absolute;
    top: 0;
    left: 0;
}

/* Controls section - Redesigned v2 */
.tilpas-controls-v2 {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: white;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--neutral-200, #eee);
}

/* Row 1: Zoom */
.zoom-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zoom-row .control-label {
    text-align: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tilpas-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--neutral-200);
    border-radius: 3px;
    outline: none;
}

.tilpas-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-primary);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.tilpas-slider:disabled {
    opacity: 0.4;
}

.zoom-input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm, 6px);
    font-size: 14px;
    text-align: center;
}

.zoom-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.zoom-reset {
    padding: 6px 12px;
    background: var(--brand-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm, 6px);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.zoom-reset:hover:not(:disabled) {
    background: var(--brand-primary-dark, #247578);
}

.zoom-reset:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Row 2: Options */
.options-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.control-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--neutral-700);
}

/* Right-aligned group - center label over content */
.control-group:last-child .control-label {
    text-align: left;
}

/* Toggle Buttons - Equal Width */
.toggle-group {
    display: flex;
    gap: 0;
}

.toggle-btn {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid var(--neutral-200);
    background: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.toggle-btn:first-child {
    border-radius: var(--radius-sm, 6px) 0 0 var(--radius-sm, 6px);
    border-right: none;
}

.toggle-btn:last-child {
    border-radius: 0 var(--radius-sm, 6px) var(--radius-sm, 6px) 0;
}

.toggle-btn.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.toggle-btn:hover:not(.active) {
    background: var(--neutral-050);
}

/* Color Presets */
.color-presets {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid var(--neutral-200);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    transition: all 0.15s;
}

.color-btn.active {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(43, 140, 145, 0.2);
}

.color-btn:hover:not(.active):not(.disabled) {
    border-color: var(--neutral-400);
}

.color-btn.custom {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--neutral-500);
    background: white;
}

.color-btn.disabled,
.color-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Checker pattern for transparent color */
:root {
    --checker-bg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect width='4' height='4' fill='%23ccc'/%3E%3Crect x='4' y='4' width='4' height='4' fill='%23ccc'/%3E%3C/svg%3E");
}

.color-input-hidden {
    display: none;
}

/* Focal point marker - refined */
.tilpas-focal-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}

.focal-crosshair {
    width: 32px;
    height: 32px;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--brand-primary), 0 0 10px rgba(0,0,0,0.3);
    position: relative;
}

/* Help text */
.help-text {
    font-size: 0.75rem;
    color: var(--neutral-500);
    margin-top: 4px;
}

/* Footer */
.tilpas-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--neutral-200, #eee);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: white;
}

/* Responsive */
@media (max-width: 600px) {
    .tilpas-body {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .tilpas-controls-v2 {
        gap: 16px;
    }
    
    .options-row {
        grid-template-columns: 1fr;
    }
}
