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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--panel-bg);
    border-radius: 0.5rem;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-color);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

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

/* Studio Sections */
.studio-section {
    margin-bottom: 1rem;
}

.studio-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* Existing Content */
.existing-content {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    min-height: 60px;
    max-height: 150px;
    overflow-y: auto;
}

.existing-content .loading {
    color: var(--text-muted);
    font-style: italic;
}

.existing-element {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    margin: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.existing-element:hover {
    border-color: var(--primary-color);
}

.existing-element.selected {
    background: #dbeafe;
    border-color: var(--primary-color);
}

.existing-element.line {
    width: 60px;
    height: 2px;
    background: var(--text-color);
    padding: 0;
}

.existing-element.line.selected {
    background: var(--primary-color);
}

.existing-actions {
    margin-top: 0.75rem;
    display: flex;
    gap: 0.5rem;
}

/* Studio Toolbar */
.studio-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.btn-format {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.875rem;
}

.btn-format:hover {
    background: var(--bg-color);
}

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

.btn-format.italic {
    font-style: italic;
}

.btn-format.underline {
    text-decoration: underline;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.studio-toolbar label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
}

.studio-toolbar select,
.studio-toolbar input[type="color"] {
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.studio-toolbar input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 2px;
    cursor: pointer;
}

/* Zone Inputs */
.zone-inputs {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.zone-row {
    display: grid;
    grid-template-columns: 80px 150px 1fr;
    gap: 0.5rem;
    align-items: center;
}

.zone-row label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.icon-select,
.zone-text {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.zone-text {
    width: 100%;
}

.zone-text:focus,
.icon-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Line Options */
.line-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.line-option {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.line-option > label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.line-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.line-settings {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.line-option input[type="checkbox"]:checked ~ .line-settings,
.line-settings.visible {
    display: flex;
}

.line-settings select,
.line-settings input[type="color"] {
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.line-settings input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 2px;
}

/* Preview */
.studio-preview {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    min-height: 60px;
}

.preview-line-above,
.preview-line-below {
    height: 2px;
    background: transparent;
    margin: 0.25rem 0;
}

.preview-line-above.visible,
.preview-line-below.visible {
    background: var(--text-color);
}

.preview-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    min-height: 24px;
}

.preview-left,
.preview-center,
.preview-right {
    font-size: 0.875rem;
}

.preview-left {
    text-align: left;
}

.preview-center {
    text-align: center;
    flex: 1;
}

.preview-right {
    text-align: right;
}

/* Apply Options */
.apply-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.apply-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.apply-options input[type="radio"] {
    width: 16px;
    height: 16px;
}

.apply-options input[type="text"] {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    width: 120px;
}

.apply-options input[type="text"]:disabled {
    background: var(--bg-color);
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 600px) {
    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .zone-row {
        grid-template-columns: 1fr;
    }

    .zone-row label {
        margin-bottom: 0.25rem;
    }

    .studio-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
}
