/* ===================================================================
   ADG 3D Engine — Modals
   Apple-style sheet dialogs with frosted glass
   =================================================================== */

/* ── Overlay ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    animation: overlayFadeIn var(--duration-normal) var(--ease-out);
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ── Modal Container (Full-screen type) ── */
.modal-container {
    background: var(--bg-secondary);
    border: 1px solid var(--separator-light);
    border-radius: var(--radius-lg);
    width: 95%;
    max-width: 95vw;
    height: 90vh;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    animation: sheetSlideUp var(--duration-enter) var(--ease-spring);
}

@keyframes sheetSlideUp {
    from {
        transform: scale(0.97) translateY(16px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ── Modal Header ── */
.modal-header {
    min-height: 48px;
    border-bottom: 1px solid var(--separator-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(0, 0, 0, 0.2);
}

.modal-header h3 {
    margin: 0;
    font: 600 14px/1 var(--font-sans);
    color: var(--text-primary);
}

/* Modal Steps */
.modal-steps {
    display: flex;
    gap: 8px;
    align-items: center;
    font: 500 12px/1 var(--font-sans);
    color: var(--text-tertiary);
}

.step.active {
    color: var(--accent);
    font-weight: 600;
}

/* ── Modal Body ── */
.modal-body {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Modal Footer ── */
.modal-footer {
    min-height: 52px;
    border-top: 1px solid var(--separator-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 16px;
    background: rgba(0, 0, 0, 0.15);
}

/* Calibration inputs in footer */
.calib-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    color: var(--text-secondary);
    font: 400 13px/1 var(--font-sans);
}

#calib-dist-input {
    background: var(--fill-quaternary);
    border: 1px solid var(--separator-light);
    color: var(--accent);
    padding: 4px 8px;
    width: 80px;
    font: 400 13px/1 var(--font-mono);
    text-align: center;
    border-radius: var(--radius-sm);
}

/* Calibration viewport */
.calib-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

#calib-canvas {
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    background: var(--bg-primary);
}

.calib-instruction {
    position: absolute;
    bottom: 24px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--separator-light);
    pointer-events: none;
    font: 400 13px/1 var(--font-sans);
    transition: opacity var(--duration-normal);
}

/* Close Button */
.btn-close,
.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 20px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--duration-fast) var(--ease-default);
    line-height: 1;
}

.btn-close:hover,
.modal-close:hover {
    color: var(--text-primary);
    background: var(--fill-quaternary);
}

/* ── AI Auto-Design Panel (Sheet Style) ── */
.auto-design-panel {
    background: var(--bg-tertiary);
    backdrop-filter: var(--glass-blur-heavy);
    -webkit-backdrop-filter: var(--glass-blur-heavy);
    border: 1px solid var(--separator-light);
    border-radius: 20px;
    width: 560px;
    max-width: 90vw;
    max-height: 85vh;
    color: var(--text-primary);
    font-family: var(--font-sans);
    animation: sheetSlideUp var(--duration-enter) var(--ease-spring);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ADG Header */
.adg-header {
    background: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--separator-light);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.adg-header h2 {
    font: 600 18px/1.2 var(--font-sans);
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* PRO Badge */
.badge-pro {
    background: var(--accent);
    color: #fff;
    -webkit-text-fill-color: #fff;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font: 700 10px/1.4 var(--font-sans);
    letter-spacing: 0.8px;
    margin-left: 4px;
}

/* ADG Body */
.adg-body {
    padding: 20px;
    flex-direction: column;
    align-items: stretch;
    overflow-y: auto;
    flex: 1;
}

.adg-body .modal-desc {
    color: var(--text-secondary);
    font: 400 13px/1.6 var(--font-sans);
    margin-bottom: 20px;
    text-align: center;
}

/* Form Grid */
.adg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

/* Form Group Card */
.adg-group {
    background: var(--fill-quaternary);
    border: 1px solid var(--separator-light);
    padding: 14px;
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-default);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.adg-group:hover {
    border-color: var(--separator);
    background: var(--fill-tertiary);
}

.adg-group label {
    display: block;
    font: 500 12px/1 var(--font-sans);
    color: var(--text-primary);
    margin-bottom: 0;
}

.adg-group label .unit {
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Inputs in ADG Modal */
.adg-group input,
.adg-group select {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--separator-light);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font: 400 14px/1 var(--font-sans);
    outline: none;
    transition: border var(--duration-fast) var(--ease-default);
    box-sizing: border-box;
}

.adg-group input:focus,
.adg-group select:focus {
    border-color: var(--accent);
    box-shadow: var(--accent-glow);
}

.adg-group select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.adg-group .help-text {
    display: block;
    font: var(--text-caption);
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* ADG Footer */
.adg-footer {
    justify-content: center;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--separator-light);
    display: flex;
}

/* Generate Button */
.adg-footer .glow-btn,
.adg-footer .btn {
    background: var(--accent);
    border: none;
    color: #fff;
    font: 600 14px/1 var(--font-sans);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
    width: 100%;
    max-width: 360px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.25);
}

.adg-footer .glow-btn:hover,
.adg-footer .btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(10, 132, 255, 0.35);
}

.adg-footer .glow-btn:active,
.adg-footer .btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(10, 132, 255, 0.2);
}