/*
 * Planning Objector — Frontend Styles
 * Modern, accessible dark-on-light design
 */

/* ---------------------------------------------------------- */
/* Custom properties / design tokens                          */
/* ---------------------------------------------------------- */
.po-wrapper {
    --po-brand:        #1a56db;
    --po-brand-dark:   #1440b3;
    --po-brand-light:  #e8f0fc;
    --po-success:      #0e7a3c;
    --po-success-bg:   #e6f4ec;
    --po-warning:      #92400e;
    --po-warning-bg:   #fef3c7;
    --po-danger:       #991b1b;
    --po-danger-bg:    #fee2e2;
    --po-neutral:      #374151;
    --po-neutral-bg:   #f3f4f6;
    --po-border:       #d1d5db;
    --po-radius:       12px;
    --po-radius-sm:    8px;
    --po-shadow:       0 4px 24px rgba(0,0,0,0.08);
    --po-shadow-card:  0 2px 8px rgba(0,0,0,0.06);
    --po-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --po-transition:   0.2s ease;

    font-family: var(--po-font);
    color: #111827;
    max-width: 780px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------------------------------------------------------- */
/* Cards                                                       */
/* ---------------------------------------------------------- */
.po-card {
    background: #fff;
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--po-shadow-card);
}

.po-card--center {
    text-align: center;
    padding: 3rem 2rem;
}

.po-card__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
    color: #111827;
}

.po-card__intro {
    color: #4b5563;
    margin: 0 0 1.5rem;
    line-height: 1.65;
}

/* ---------------------------------------------------------- */
/* Form                                                        */
/* ---------------------------------------------------------- */
.po-field-group {
    margin-bottom: 1.25rem;
}

.po-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    margin-bottom: 0.4rem;
}

.po-required {
    color: var(--po-danger);
    margin-left: 2px;
}

.po-input,
.po-select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--po-border);
    border-radius: var(--po-radius-sm);
    font-size: 1rem;
    font-family: var(--po-font);
    color: #111827;
    background: #fff;
    transition: border-color var(--po-transition), box-shadow var(--po-transition);
    box-sizing: border-box;
}

.po-input:focus,
.po-select:focus {
    outline: none;
    border-color: var(--po-brand);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.po-input::placeholder {
    color: #9ca3af;
}

/* ---------------------------------------------------------- */
/* Buttons                                                     */
/* ---------------------------------------------------------- */
.po-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border: 2px solid transparent;
    border-radius: var(--po-radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--po-font);
    cursor: pointer;
    transition: background var(--po-transition), transform var(--po-transition), box-shadow var(--po-transition);
    text-decoration: none;
    line-height: 1;
}

.po-btn:active { transform: scale(0.98); }

.po-btn--primary {
    background: var(--po-brand);
    color: #fff;
    width: 100%;
    justify-content: center;
    font-size: 1.05rem;
    padding: 0.9rem 1.5rem;
    box-shadow: 0 4px 14px rgba(26,86,219,0.25);
}
.po-btn--primary:hover { background: var(--po-brand-dark); box-shadow: 0 6px 20px rgba(26,86,219,0.35); }
.po-btn--primary:disabled { opacity: 0.6; cursor: not-allowed; }

.po-btn--secondary {
    background: #fff;
    color: var(--po-brand);
    border-color: var(--po-brand);
}
.po-btn--secondary:hover { background: var(--po-brand-light); }

.po-btn--ghost {
    background: transparent;
    color: #6b7280;
    border-color: var(--po-border);
}
.po-btn--ghost:hover { background: var(--po-neutral-bg); color: #374151; }

.po-btn__icon { font-size: 1.1em; }

#po-submit {
    width: auto !important;
    inline-size: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    display: inline-flex !important;
    margin: 0 auto;
    padding-left: 1.1rem;
    padding-right: 1.1rem;
}

#po-app #po-form {
    display: flex;
    flex-direction: column;
}

#po-app #po-form #po-submit.po-btn--primary {
    align-self: center;
    flex: 0 0 auto !important;
    width: auto !important;
    inline-size: auto !important;
    max-width: none !important;
}

.po-complete-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    background: var(--po-success-bg);
    color: var(--po-success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
}

#po-step-complete .po-card {
    opacity: 0;
    transform: translateY(8px);
}

#po-step-complete.po-step--animate .po-card {
    animation: po-complete-card-in 420ms ease forwards;
}

#po-step-complete .po-complete-icon {
    transform: scale(0.86);
}

#po-step-complete.po-step--animate .po-complete-icon {
    animation: po-complete-check-pop 520ms cubic-bezier(.2,.7,.2,1.15) 120ms forwards,
               po-complete-check-pulse 1400ms ease 700ms 1;
}

@keyframes po-complete-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes po-complete-check-pop {
    0% { transform: scale(0.86); }
    70% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes po-complete-check-pulse {
    0% { box-shadow: 0 0 0 0 rgba(14, 122, 60, 0.22); }
    70% { box-shadow: 0 0 0 10px rgba(14, 122, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(14, 122, 60, 0); }
}

@media (prefers-reduced-motion: reduce) {
    #po-step-complete .po-card,
    #po-step-complete .po-complete-icon {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    .po-scanner__beam {
        animation: none !important;
        transform: translateX(calc((min(360px, 78vw) - 96px) / 2)) !important;
    }
}

/* ---------------------------------------------------------- */
/* Steps (show/hide)                                          */
/* ---------------------------------------------------------- */
.po-step { display: none; }
.po-step--active { display: block; }
#po-app .po-step[hidden] { display: none !important; }
#po-app .po-step:not(.po-step--active) { display: none !important; }
#po-app .po-step.po-step--active { display: block !important; }

/* ---------------------------------------------------------- */
/* Processing Scanner                                         */
/* ---------------------------------------------------------- */
.po-scanner {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.po-scanner__rail {
    width: min(360px, 78vw);
    height: 28px;
    border-radius: 999px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #0f1117 0%, #0a0d13 100%);
    border: 1px solid #1f2937;
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.65), 0 8px 24px rgba(0, 0, 0, 0.2);
}

.po-scanner__beam {
    position: absolute;
    top: 3px;
    left: 0;
    width: 96px;
    height: 22px;
    border-radius: 999px;
    background: radial-gradient(circle at center, rgba(255, 120, 120, 0.95) 0%, rgba(235, 34, 34, 0.88) 56%, rgba(180, 8, 8, 0.75) 100%);
    box-shadow: 0 0 18px rgba(245, 37, 37, 0.9), 0 0 34px rgba(245, 37, 37, 0.6), inset 0 0 10px rgba(255, 200, 200, 0.35);
    animation: po-kitt-scan 1.5s cubic-bezier(.45,0,.55,1) infinite alternate;
}

@keyframes po-kitt-scan {
    from { transform: translateX(0); }
    to { transform: translateX(calc(min(360px, 78vw) - 96px)); }
}

.po-processing__title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
}

.po-processing__status {
    color: #6b7280;
    font-size: 0.95rem;
    margin: 0 0 1.5rem;
    min-height: 1.5em;
}

/* ---------------------------------------------------------- */
/* Progress bar                                               */
/* ---------------------------------------------------------- */
.po-progress-bar {
    height: 6px;
    background: var(--po-neutral-bg);
    border-radius: 99px;
    overflow: hidden;
    max-width: 320px;
    margin: 0 auto;
}

.po-progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--po-brand), #60a5fa);
    border-radius: 99px;
    width: 0%;
    transition: width 0.4s ease;
}

/* ---------------------------------------------------------- */
/* Application summary                                        */
/* ---------------------------------------------------------- */
.po-app-summary {
    border-left: 5px solid var(--po-brand);
    position: relative;
}

.po-app-summary__badge {
    margin-bottom: 0.75rem;
}

.po-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--po-neutral-bg);
    color: var(--po-neutral);
}

.po-badge--pending   { background: var(--po-warning-bg); color: var(--po-warning); }
.po-badge--approved  { background: var(--po-success-bg); color: var(--po-success); }
.po-badge--refused   { background: var(--po-danger-bg);  color: var(--po-danger); }
.po-badge--current   { background: var(--po-brand-light); color: var(--po-brand); }

.po-app-meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.3rem 1rem;
    margin: 0;
    font-size: 0.9rem;
}

.po-app-meta dt {
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.po-app-meta dd {
    margin: 0;
    color: #111827;
}

/* ---------------------------------------------------------- */
/* Objection grounds                                          */
/* ---------------------------------------------------------- */
.po-objections {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.po-objection {
    background: #fff;
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--po-shadow-card);
    border-left: 5px solid var(--po-border);
    transition: box-shadow var(--po-transition);
}

.po-objection:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.po-objection--strong   { border-left-color: var(--po-danger); }
.po-objection--moderate { border-left-color: #f59e0b; }
.po-objection--weak     { border-left-color: #9ca3af; }

.po-objection__header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.po-objection__number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--po-brand);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.po-objection__title {
    font-size: 1rem;
    font-weight: 700;
    color: #111827;
    flex: 1;
    line-height: 1.4;
    margin: 0;
}

.po-strength-badge {
    flex-shrink: 0;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.po-strength-badge--strong   { background: var(--po-danger-bg); color: var(--po-danger); }
.po-strength-badge--moderate { background: #fef3c7; color: #92400e; }
.po-strength-badge--weak     { background: var(--po-neutral-bg); color: #6b7280; }

.po-objection__detail {
    color: #374151;
    font-size: 0.93rem;
    line-height: 1.7;
    margin: 0 0 0.75rem;
}

.po-objection__policies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.po-policy-tag {
    background: var(--po-brand-light);
    color: var(--po-brand-dark);
    border: 1px solid #bfdbfe;
    padding: 0.2rem 0.7rem;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 500;
}

/* ---------------------------------------------------------- */
/* Results actions                                            */
/* ---------------------------------------------------------- */
.po-results-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* ---------------------------------------------------------- */
/* Documents used                                             */
/* ---------------------------------------------------------- */
.po-documents-used {
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius-sm);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 2rem;
}

.po-documents-used summary {
    cursor: pointer;
    user-select: none;
    padding: 0.4rem 0;
    font-weight: 600;
    color: var(--po-brand);
}

.po-documents-list {
    list-style: none;
    padding: 0.5rem 0 0;
    margin: 0;
}

.po-documents-list li {
    padding: 0.25rem 0;
    border-top: 1px solid var(--po-border);
}

.po-documents-list li:first-child {
    border-top: none;
}

.po-documents-list a {
    color: var(--po-brand);
    text-decoration: underline;
}

/* ---------------------------------------------------------- */
/* Alerts                                                     */
/* ---------------------------------------------------------- */
.po-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--po-radius-sm);
    font-size: 0.9rem;
    margin-top: 1rem;
}

.po-alert--error {
    background: var(--po-danger-bg);
    color: var(--po-danger);
    border: 1px solid #fca5a5;
}

.po-alert--warning {
    background: var(--po-warning-bg);
    color: var(--po-warning);
    border: 1px solid #fcd34d;
}

.po-confidence-explanation {
    color: #4b5563;
    font-size: 0.9rem;
}

.po-traceability {
    margin-top: 0.75rem;
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius-sm);
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
}

.po-traceability summary {
    cursor: pointer;
    font-weight: 600;
    color: #1f2937;
}

.po-traceability ul {
    margin: 0.6rem 0 0;
    padding-left: 1rem;
}

.po-traceability li {
    margin: 0.25rem 0;
    color: #374151;
}

/* ---------------------------------------------------------- */
/* Disclaimer                                                 */
/* ---------------------------------------------------------- */
.po-disclaimer {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
}

.po-submit-nav {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}

.po-submit-nav a {
    color: var(--po-brand);
    text-decoration: none;
    font-weight: 600;
}

.po-submit-nav a:hover {
    text-decoration: underline;
}

.po-account-panel {
    margin-top: 1rem;
    border: 1px solid var(--po-border);
    border-radius: var(--po-radius-sm);
    padding: 0.9rem 1rem;
    background: #f9fafb;
}

.po-account-panel h3,
.po-account-panel h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.po-account-panel p {
    margin: 0 0 0.8rem;
    color: #374151;
    font-size: 0.88rem;
}

.po-history-list {
    margin: 0;
    padding-left: 1rem;
}

.po-history-list li {
    margin: 0.35rem 0;
    font-size: 0.85rem;
}

/* ---------------------------------------------------------- */
/* Copy success toast                                         */
/* ---------------------------------------------------------- */
.po-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: #111827;
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--po-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    z-index: 9999;
    pointer-events: none;
}

.po-toast.po-toast--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------------------------------------------------------- */
/* Responsive                                                 */
/* ---------------------------------------------------------- */
@media (max-width: 600px) {
    .po-card { padding: 1.25rem; }
    .po-app-meta { grid-template-columns: 1fr; }
    .po-app-meta dt { margin-top: 0.4rem; }
    .po-results-actions { flex-direction: column; }
    #po-app #po-form #po-submit.po-btn--primary {
        align-self: center;
        width: auto !important;
        inline-size: auto !important;
        max-width: 240px !important;
        min-width: 0 !important;
    }
    .po-btn--secondary, .po-btn--ghost { width: 100%; justify-content: center; }
}

/* ---------------------------------------------------------- */
/* Print styles                                               */
/* ---------------------------------------------------------- */
@media print {
    .po-results-actions,
    .po-scanner,
    #po-step-input,
    #po-step-processing,
    #po-step-complete { display: none !important; }

    .po-step { display: block !important; }
    .po-card { box-shadow: none !important; border: 1px solid #ccc; }
    .po-objection { break-inside: avoid; }

    .po-wrapper {
        max-width: none;
        padding: 0;
    }
}
