/* ===========================================
   SUMMARY MODAL — Bottom Sheet (all viewports)
   3-step flow: Profile selection → Loading → Result
   =========================================== */

/* --- Overlay --- */
#summaryModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#summaryModal.visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Card (bottom sheet) --- */
.summary-card {
    width: 100%;
    max-width: 600px;
    height: auto;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 20px 20px 0 0;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, #1f1f23 0%, #18181b 100%);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    /* Slide up */
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

#summaryModal.visible .summary-card {
    transform: translateY(0);
}

/* --- Header with drag handle --- */
.summary-header {
    padding: 8px 1.25rem 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    position: relative;
}

/* Drag handle */
.summary-header::before {
    content: '';
    display: block;
    width: 36px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    margin: 0 auto 12px;
    flex-basis: 100%;
}

.summary-title {
    flex: 1;
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.summary-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-header-actions .tools-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: none;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.summary-header-actions .tools-btn:hover {
    opacity: 1;
}

#refreshSummaryBtn {
    color: var(--accent);
}

#refreshSummaryBtn:hover {
    background: rgba(59, 130, 246, 0.15);
}

/* --- Body --- */
.summary-body {
    flex: 1;
    padding: 1rem 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --- Profile Grid (Step 1: Config) --- */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1rem;
}

.profile-option {
    background: var(--input-bg);
    border: 1px solid var(--border-medium);
    min-height: 56px;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.2s ease;
}

.profile-option:hover {
    border-color: var(--text-secondary);
}

.profile-option.selected {
    border-color: var(--accent);
    border-width: 2px;
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.25);
}

.profile-option.has-summary {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.08);
}

.profile-option.has-summary.selected {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.15);
}

.profile-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.profile-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.summary-indicator {
    color: var(--success);
    font-size: 0.75rem;
    margin-left: 6px;
}

/* --- Result (Step 3) --- */
.summary-result {
    flex: 1;
    background: var(--input-bg);
    border-radius: 12px;
    padding: 1rem;
    overflow-y: auto;
    font-size: 0.93rem;
    line-height: 1.6;
    border: 1px solid var(--border-subtle);
    display: none;
}

.summary-result.visible {
    display: block;
}

/* --- Footer — full-width stacked buttons --- */
.summary-footer {
    padding: 16px 20px;
    border-top: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.summary-footer .toast-btn {
    width: 100%;
    justify-content: center;
    padding: 14px 20px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
}

.summary-footer .toast-btn:active {
    transform: scale(0.97);
}

.summary-footer .toast-btn.primary {
    background: linear-gradient(135deg, var(--accent, #3bf692), #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    border: none;
}

.summary-footer .toast-btn.primary:active {
    filter: brightness(0.9);
}

.summary-footer .toast-btn:not(.primary) {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #fafafa);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Loading step */
#summaryLoadingStep {
    padding: 2.5rem 1rem !important;
}

/* Result step — scrollable */
#summaryResultStep {
    max-height: 55vh;
}

/* Custom textarea */
.setting-group textarea.config-text {
    border-radius: 12px;
    font-size: 0.95rem;
    padding: 12px;
}


/* ===========================================
   MOBILE: Device-specific tweaks
   =========================================== */
@media (max-width: 768px) {

    .summary-card {
        max-width: 100%;
        /* Safe area for notch devices */
        padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    }
}
