/**
 * Deactivation Feedback Modal — Add as Preferred Source on Google
 */

/* ─── Overlay ─────────────────────────────────────────────────────────────── */
.aaps-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 16px;
}

.aaps-modal-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* ─── Modal Card ──────────────────────────────────────────────────────────── */
.aaps-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    max-width: 560px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    transform: translateY(24px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.aaps-modal-overlay.is-visible .aaps-modal {
    transform: translateY(0) scale(1);
}

/* ─── Modal Header ────────────────────────────────────────────────────────── */
.aaps-modal__header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 24px 24px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px 12px 0 0;
    position: relative;
}

.aaps-modal__header-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.aaps-modal__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    color: #f1f5f9;
    line-height: 1.3;
}

.aaps-modal__subtitle {
    margin: 0;
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
}

/* Close (×) in header */
.aaps-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}

.aaps-modal__close:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #f1f5f9;
}

.aaps-modal__close:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ─── Modal Body ──────────────────────────────────────────────────────────── */
.aaps-modal__body {
    padding: 24px 24px 8px;
}

/* ─── Reason Card Grid ────────────────────────────────────────────────────── */
.aaps-reason-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.aaps-reason-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    background: #f8fafc;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    user-select: none;
}

.aaps-reason-card:hover {
    border-color: #a5b4fc;
    background: #faf9ff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

/* Hide the raw radio input */
.aaps-reason-card__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.aaps-reason-card__icon {
    color: #94a3b8;
    transition: color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aaps-reason-card__label {
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    line-height: 1.35;
    transition: color 0.15s ease;
}

/* Selected state */
.aaps-reason-card.is-selected {
    border-color: #6366f1;
    background: #f5f3ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.aaps-reason-card.is-selected .aaps-reason-card__icon {
    color: #6366f1;
}

.aaps-reason-card.is-selected .aaps-reason-card__label {
    color: #4338ca;
    font-weight: 600;
}

/* ─── Contextual Textarea ─────────────────────────────────────────────────── */
.aaps-reason-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    color: #1e293b;
    background: #f8fafc;
    box-sizing: border-box;
    resize: vertical;
    min-height: 76px;
    margin-bottom: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aaps-reason-textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    outline: none;
    background: #fff;
}

/* ─── Contact Section ─────────────────────────────────────────────────────── */
.aaps-contact-section {
    padding: 14px 16px;
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
}

.aaps-contact-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 10px;
}

.aaps-contact-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #6366f1;
    cursor: pointer;
    flex-shrink: 0;
}

.aaps-email-wrapper {
    margin-top: 4px;
}

.aaps-email-input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    box-sizing: border-box;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aaps-email-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    outline: none;
}

/* ─── Error Message ───────────────────────────────────────────────────────── */
.aaps-form-error {
    font-size: 13px;
    color: #dc2626;
    font-weight: 500;
    min-height: 20px;
    margin-bottom: 4px;
}

/* ─── Modal Footer ────────────────────────────────────────────────────────── */
.aaps-modal__footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px 24px;
    border-top: 1px solid #f1f5f9;
}

/* Submit button */
.aaps-modal__submit {
    padding: 9px 20px;
    background: #1e293b;
    border: 1.5px solid #1e293b;
    border-radius: 7px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.aaps-modal__submit:hover {
    background: #0f172a;
    border-color: #0f172a;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
}

.aaps-modal__submit:disabled {
    background: #e2e8f0;
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

/* Spinner on disabled submit */
.aaps-modal__submit:disabled::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top-color: #94a3b8;
    border-radius: 50%;
    animation: aaps-spin 0.8s linear infinite;
}

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

.aaps-modal__submit:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Skip link */
.aaps-modal__skip {
    font-size: 13px;
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.aaps-modal__skip:hover {
    color: #4338ca;
    text-decoration: underline;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
    .aaps-reason-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .aaps-modal__header {
        padding: 18px 16px 16px;
    }

    .aaps-modal__body {
        padding: 18px 16px 8px;
    }

    .aaps-modal__footer {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px 20px;
    }

    .aaps-modal__submit {
        justify-content: center;
    }

    .aaps-modal__skip {
        text-align: center;
    }
}

@media (max-width: 380px) {
    .aaps-reason-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
