/**
 * UKSE Partner Portal Styles
 *
 * @package LSE_Clean_AFS
 * @since 1.21.0
 */

/* =============================================================================
   Hero
   ============================================================================= */

.ukse-portal-hero {
    background: linear-gradient(to right, #000032, #6ACAF3);
    padding: 80px 0;
    margin-bottom: 0;
    position: relative;
}

.ukse-portal-hero .ukse-schools-hero__wrap {
    position: relative;
    z-index: 1;
}

.ukse-portal-hero .ukse-schools-hero__title {
    color: #ffffff;
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.ukse-portal-hero .ukse-schools-hero__intro {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.15rem;
    max-width: 600px;
}

.ukse-portal-hero .ukse-schools-hero__intro p {
    margin: 0;
}

/* Hero image container */
.ukse-portal-hero .ukse-schools-hero__media {
    position: relative;
    z-index: 1;
}

.ukse-portal-hero .ukse-schools-hero__media img {
    height: 300px;
    width: auto;
    object-fit: contain;
}

/* =============================================================================
   Portal Section
   ============================================================================= */

.portal-section {
    padding: 60px 0;
    background: #f7f9fc;
    min-height: 60vh;
}

.portal-content {
    max-width: 100%;
}

/* =============================================================================
   Portal Cards
   ============================================================================= */

.portal-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(0, 0, 50, 0.08);
    padding: 40px;
    max-width: 720px;
    margin: 0 auto;
}

.portal-card h2 {
    color: var(--lse-dark-blue, #000032);
    font-size: 1.75rem;
    margin: 0 0 0.75rem;
}

.portal-card > p {
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 2rem;
}

.portal-card--request {
    max-width: 560px;
}

.portal-card--submit {
    max-width: 800px;
}

.portal-card--success {
    text-align: center;
    max-width: 560px;
}

.portal-card--success h2 {
    color: #059669;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: rgba(5, 150, 105, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    width: 40px;
    height: 40px;
    color: #059669;
}

/* =============================================================================
   Portal Messages
   ============================================================================= */

.portal-message {
    padding: 16px 20px;
    border-radius: 10px;
    margin-top: 1.5rem;
}

.portal-message h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.portal-message p {
    margin: 0;
}

.portal-message--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.portal-message--error h2 {
    color: #991b1b;
}

.portal-message--success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.portal-message--warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

/* Admin debug panel */
.admin-debug-panel {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.admin-debug-panel > p {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #475569;
}

.debug-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.debug-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.debug-table td:first-child {
    font-weight: 500;
    color: #64748b;
    width: 40%;
}

.debug-table .status-ok {
    color: #059669;
    font-weight: 600;
}

.debug-table .status-fail {
    color: #dc2626;
    font-weight: 600;
}

/* Admin debug link fallback */
.admin-debug-link {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed #cbd5e1;
}

.admin-debug-link p {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.admin-debug-link input[type="text"] {
    width: 100%;
    padding: 8px;
    margin: 8px 0;
    font-family: monospace;
    font-size: 0.8rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.admin-debug-link .home-button--small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.mail-error-detail {
    margin-top: 0.75rem;
    color: #6b7280;
}

/* =============================================================================
   Portal Form
   ============================================================================= */

.portal-form {
    margin-top: 1.5rem;
}

.portal-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 2rem;
}

.portal-fieldset legend {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--lse-dark-blue, #000032);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid rgba(230, 0, 126, 0.2);
    width: 100%;
}

.portal-form__field {
    margin-bottom: 1.5rem;
}

.portal-form__field--half {
    max-width: 50%;
}

.portal-form__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.portal-form__field label {
    display: block;
    font-weight: 600;
    color: var(--lse-dark-blue, #000032);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.portal-form__field label .required {
    color: #e6007e;
}

.portal-form__field label .optional {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.85rem;
}

.portal-form__field input[type="text"],
.portal-form__field input[type="email"],
.portal-form__field input[type="url"],
.portal-form__field input[type="tel"],
.portal-form__field textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff;
}

.portal-form__field input:focus,
.portal-form__field textarea:focus {
    outline: none;
    border-color: #e6007e;
    box-shadow: 0 0 0 3px rgba(230, 0, 126, 0.1);
}

.portal-form__field input::placeholder,
.portal-form__field textarea::placeholder {
    color: #9ca3af;
}

/* Readonly field styling */
.portal-form__field input[readonly],
.portal-form__field--readonly {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: #e5e7eb;
}

.portal-form__field input[readonly]:focus {
    border-color: #e5e7eb;
    box-shadow: none;
}

.portal-form__field textarea {
    resize: vertical;
    min-height: 120px;
}

.portal-form__field input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.portal-form__field input[type="file"]:hover {
    border-color: #e6007e;
    background: rgba(230, 0, 126, 0.02);
}

.portal-form__field input[type="file"]:focus {
    outline: none;
    border-color: #e6007e;
}

.field-hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0.5rem 0 0;
}

.gallery-count {
    font-size: 0.9rem;
    color: var(--lse-dark-blue, #000032);
    font-weight: 500;
    margin: 0.5rem 0 0;
}

.gallery-count.error {
    color: #dc2626;
}

/* =============================================================================
   Current Media Preview
   ============================================================================= */

.current-media {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f3f4f6;
    border-radius: 10px;
}

.current-label {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0 0 0.75rem;
}

.current-media img {
    border-radius: 6px;
    max-height: 80px;
    width: auto;
}

.gallery-thumbs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.gallery-thumbs img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.more-count {
    background: #e5e7eb;
    color: #4b5563;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Editable gallery with remove controls */
.gallery-thumbs--editable {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.gallery-thumb-item {
    position: relative;
    display: inline-block;
}

.gallery-thumb-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    transition: opacity 0.2s;
}

.gallery-thumb-item:has(input:checked) img {
    opacity: 0.4;
}

.current-media__item {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.remove-media {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: #dc2626;
    user-select: none;
}

.remove-media input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.gallery-thumb-item .remove-media {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.gallery-thumb-item .remove-media input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.gallery-thumb-item .remove-media span {
    line-height: 1;
}

/* =============================================================================
   Form Actions
   ============================================================================= */

.portal-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.portal-form__actions .home-button {
    min-width: 200px;
    border-radius: 50px;
}

/* Outline button: white text on hover with gradient background */
.portal-form__actions .home-button--outline:hover,
.portal-form__actions .home-button--outline:focus,
.portal-step__nav .home-button--outline:hover,
.portal-step__nav .home-button--outline:focus {
    background: linear-gradient(135deg, #EE7218 0%, #E6007E 100%) !important;
    color: #ffffff !important;
    border-color: transparent;
}

.portal-form__actions .home-button .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-form__actions .home-button.is-loading .btn-text {
    display: none;
}

.portal-form__actions .home-button.is-loading .btn-loading {
    display: inline-flex !important;
}

/* =============================================================================
   Validation States
   ============================================================================= */

.portal-form__field.has-error input,
.portal-form__field.has-error textarea,
.portal-form__field.has-error select {
    border-color: #dc2626;
    background-color: #fef2f2;
}

.portal-form__field.has-error .field-error {
    display: block;
}

.field-error {
    display: none;
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* =============================================================================
   Form Error Banner (prominent, top of form)
   ============================================================================= */

.ukse-form-error {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 2px solid #dc2626;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
}

.ukse-form-error__icon {
    flex-shrink: 0;
    font-size: 1.75rem;
    line-height: 1;
    color: #dc2626;
}

.ukse-form-error__content {
    flex: 1;
}

.ukse-form-error__content strong {
    display: block;
    font-size: 1.1rem;
    color: #991b1b;
    margin-bottom: 0.35rem;
}

.ukse-form-error__content p {
    margin: 0;
    font-size: 0.95rem;
    color: #b91c1c;
    line-height: 1.5;
}

.ukse-form-error__list {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
    color: #b91c1c;
    line-height: 1.6;
}

.ukse-form-error__list li {
    margin-bottom: 0.25rem;
}

.ukse-form-error__list li:last-child {
    margin-bottom: 0;
}

/* =============================================================================
   Inline Field Error (next to specific field)
   ============================================================================= */

.ukse-field-error {
    display: block;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 0 6px 6px 0;
    color: #991b1b;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
}

/* =============================================================================
   Field Error Highlight (has-error enhancements)
   ============================================================================= */

.portal-form__field.has-error {
    position: relative;
}

.portal-form__field.has-error input[type="file"] {
    border-color: #dc2626;
    background: #fef2f2;
}

.portal-form__field.has-error .current-media,
.portal-form__field.has-error .new-media-preview {
    border-color: #dc2626;
    background: #fef2f2;
}

/* Pulse animation to draw attention */
.ukse-field-pulse {
    animation: ukse-pulse 0.5s ease-in-out 2;
}

@keyframes ukse-pulse {
    0%, 100% {
        box-shadow: none;
    }
    50% {
        box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.3);
    }
}

/* =============================================================================
   New Media Previews (client-side)
   ============================================================================= */

.new-media-preview {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border: 1px dashed #86efac;
    border-radius: 10px;
}

.new-media-preview .current-label {
    color: #166534;
    font-weight: 500;
}

.new-media-preview .preview-content {
    margin-top: 0.5rem;
}

.new-media-preview .gallery-thumb-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.remove-preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 0.5rem;
    transition: background 0.2s, color 0.2s;
}

.remove-preview-btn:hover {
    background: #dc2626;
    color: #fff;
}

/* Gallery preview remove button (positioned on thumbnail) */
.new-gallery-preview .gallery-thumb-item {
    position: relative;
    display: inline-block;
}

.new-gallery-preview .gallery-thumb-item .remove-preview-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

/* =============================================================================
   Email Change Request
   ============================================================================= */

.email-change-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #e6007e;
    text-decoration: none;
}

.email-change-link:hover {
    text-decoration: underline;
}

.email-change-fields {
    margin-top: 1rem;
    padding: 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}

.email-change-fields .portal-form__field {
    margin-bottom: 1rem;
}

.email-change-fields .portal-form__field:last-child {
    margin-bottom: 0;
}

.email-change-fields textarea {
    min-height: 60px;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .ukse-portal-hero {
        padding: 40px 0;
    }

    .ukse-portal-hero .ukse-schools-hero__title {
        font-size: 2rem;
    }

    .portal-section {
        padding: 40px 0;
    }

    .portal-card {
        padding: 24px;
        border-radius: 14px;
    }

    .portal-card h2 {
        font-size: 1.5rem;
    }

    .portal-form__row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .portal-form__field--half {
        max-width: 100%;
    }

    .portal-fieldset legend {
        font-size: 1.05rem;
    }
}

@media (max-width: 480px) {
    .portal-card {
        padding: 20px 16px;
    }

    .current-media {
        padding: 0.75rem;
    }

    .gallery-thumbs img {
        width: 50px;
        height: 50px;
    }
}

/* Gallery error badge */
.gallery-thumb-item.has-error {
    position: relative;
    border: 2px solid #e74c3c;
    border-radius: 6px;
}
.gallery-error-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Gallery error text (shows actual reasons, not generic text) */
.gallery-error-helper {
    font-size: 0.9rem;
    color: #b91c1c;
    margin: 0.5rem 0 0.75rem;
    padding: 8px 12px;
    background: #fef2f2;
    border-left: 3px solid #e74c3c;
    border-radius: 0 4px 4px 0;
    line-height: 1.5;
}

/* ====== PHASE 2.1: COLLAPSIBLE FIELDSETS & DESCRIPTION SECTIONS ====== */

/* Collapsible fieldset toggle */
.portal-fieldset--collapsible legend {
    width: 100%;
}

.fieldset-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fieldset-toggle:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.toggle-icon {
    font-size: 1.25rem;
    font-weight: bold;
    color: #6b7280;
}

.fieldset-content {
    padding-top: 1.25rem;
}

.fieldset-intro {
    color: #6b7280;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

/* Optional fieldset styling — subtle solid pastel body + highlighted header */
.portal-fieldset--optional {
    background: #F6FBFF;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-top: 0.5rem;
}

.portal-fieldset--optional > legend {
    width: 100%;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

/* Header bar: solid pastel (slightly stronger than body) */
.portal-fieldset--optional .fieldset-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #E7F3FF;
    border: 1px solid #D6E9F8;
    border-radius: 12px;
    padding: 12px 16px;
}

.portal-fieldset--optional .fieldset-toggle:hover {
    background: #DDEEFF;
}

/* Keep icon alignment */
.portal-fieldset--optional .toggle-icon {
    margin-left: 12px;
}

/* Three-column row for key info fields */
.portal-form__row--thirds {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

@media (max-width: 768px) {
    .portal-form__row--thirds {
        grid-template-columns: 1fr;
    }
}

/* Divider */
.portal-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 1.5rem 0;
}

/* Description sections container */
.description-sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.description-section {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.section-number {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.remove-section {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #9ca3af;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}

.remove-section:hover {
    color: #ef4444;
}

/* Checkbox field styling */
.portal-form__field--checkbox {
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.95rem;
    color: #374151;
}

/* Secondary button style for Add Section */
.portal-btn--secondary {
    background: transparent;
    border: 1px dashed #9ca3af;
    color: #6b7280;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.portal-btn--secondary:hover {
    border-color: #6b7280;
    color: #374151;
    background: #f9fafb;
}

/* ====== PHASE 2.1.1: PROFILE COMPLETION BAR ====== */

.ukse-profile-completion {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.completion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.completion-label {
    font-weight: 600;
    color: #374151;
    font-size: 0.95rem;
}

.completion-count {
    font-size: 0.85rem;
    color: #6b7280;
}

.completion-bar-wrapper {
    background: #e5e7eb;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.completion-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease, background-color 0.3s ease;
}

.completion-bar--low {
    background: linear-gradient(90deg, #ef4444, #f97316);
}

.completion-bar--medium {
    background: linear-gradient(90deg, #f97316, #eab308);
}

.completion-bar--complete {
    background: linear-gradient(90deg, #22c55e, #10b981);
}

.completion-percent {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    text-align: right;
}

.completion-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.completion-note {
    font-size: 0.9rem;
    color: #6b7280;
    margin: 0 0 0.75rem 0;
}

.completion-missing-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.completion-missing-list li {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid #fcd34d;
}

.completion-missing-list .completion-more {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #d1d5db;
}

/* ====== CHARACTER COUNTERS ====== */

.char-counter {
    display: flex;
    justify-content: flex-end;
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 4px;
}

.char-counter--inline {
    margin-top: 2px;
}

.char-counter .char-count {
    font-weight: 500;
}

.char-counter--warning .char-count {
    color: #f59e0b;
}

.char-counter--over .char-count {
    color: #dc2626;
    font-weight: 600;
}

/* ====== PHASE 3: STEPPER PAGINATION ====== */

/* Stepper Navigation Header */
.portal-stepper {
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.portal-stepper__steps {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.portal-stepper__step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.portal-stepper__step:hover:not(.portal-stepper__step--active) {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.portal-stepper__step--active {
    background: linear-gradient(135deg, rgba(230, 0, 126, 0.08) 0%, rgba(238, 114, 24, 0.08) 100%);
    border-color: #e6007e;
}

.portal-stepper__step--completed {
    background: #ecfdf5;
    border-color: #10b981;
}

.step-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #e5e7eb;
    color: #6b7280;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.portal-stepper__step--active .step-number {
    background: linear-gradient(135deg, #e6007e 0%, #EE7218 100%);
    color: #ffffff;
}

.portal-stepper__step--completed .step-number {
    background: #10b981;
    color: #ffffff;
}

.portal-stepper__step--completed .step-number::before {
    content: "✓";
}

.step-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
}

.portal-stepper__step--active .step-label {
    color: #e6007e;
}

.portal-stepper__step--completed .step-label {
    color: #059669;
}

/* Step Containers - increased specificity for cross-browser consistency */
.portal-form .portal-step {
    display: none !important;
}

.portal-form .portal-step.portal-step--active {
    display: block !important;
    animation: stepFadeIn 0.3s ease;
}

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Step Navigation Buttons */
.portal-step__nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.portal-step__nav .home-button {
    min-width: 180px;
}

.portal-nav-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Actions - always visible at bottom */
.portal-form__actions {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    z-index: 10;
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: 2px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

/* Submit button disabled state */
#portal-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #9ca3af;
}

#portal-submit-btn:disabled:hover {
    background: #9ca3af;
}

/* Responsive Stepper */
@media (max-width: 768px) {
    .portal-stepper__steps {
        flex-direction: column;
        gap: 0.75rem;
    }

    .portal-stepper__step {
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }

    .step-number {
        margin-bottom: 0;
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }

    .step-label {
        text-align: left;
    }

    .portal-step__nav {
        flex-direction: column;
        gap: 0.75rem;
    }

    .portal-step__nav .home-button {
        width: 100%;
    }
}

/* =============================================================================
   F1.7+: Portal Choice Screen & Section Routing
   ============================================================================= */

/* Choice Screen Card */
.portal-card--choice {
    text-align: center;
    padding: 2rem;
}

.portal-card--choice h2 {
    font-size: 1.75rem;
    color: #111827;
    margin-bottom: 0.5rem;
}

.portal-choice__intro {
    color: #6b7280;
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Choice Option Cards */
.portal-choice__options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 500px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .portal-choice__options {
        flex-direction: row;
        max-width: 700px;
        gap: 1.5rem;
    }
}

.portal-choice__option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    flex: 1;
}

.portal-choice__option:hover,
.portal-choice__option:focus {
    border-color: #f97316;
    background: #fff;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.15);
    text-decoration: none;
}

.portal-choice__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.portal-choice__icon--analytics {
    background: #dbeafe;
    color: #2563eb;
}

.portal-choice__icon--profile {
    background: #fef3c7;
    color: #d97706;
}

.portal-choice__option:hover .portal-choice__icon--analytics {
    background: #2563eb;
    color: #fff;
}

.portal-choice__option:hover .portal-choice__icon--profile {
    background: #d97706;
    color: #fff;
}

.portal-choice__text {
    text-align: center;
}

.portal-choice__label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.25rem;
}

.portal-choice__desc {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Back Link */
.portal-back-link {
    display: inline-block;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: color 0.2s ease;
}

.portal-back-link:hover {
    color: #f97316;
    text-decoration: none;
}

/* Analytics View (Full Page) */
.portal-card--analytics-view {
    padding: 2rem;
}

.portal-analytics-header {
    margin-bottom: 1rem;
}

.portal-card--analytics-view h2 {
    font-size: 1.5rem;
    color: #111827;
    margin-bottom: 0.5rem;
}

.portal-card--analytics-view > p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Expanded analytics (no toggle needed) */
.portal-analytics--expanded {
    border: none;
    margin-bottom: 0;
    background: transparent;
}

.portal-analytics--expanded .portal-analytics__content {
    display: block !important;
}

.portal-analytics-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

/* Profile Header (Back Link) */
.portal-profile-header {
    margin-bottom: 0.5rem;
}

/* =============================================================================
   F1.7: Partner Portal Lead Analytics Section
   ============================================================================= */

.portal-analytics {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.portal-analytics__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
}

.portal-analytics__header:hover {
    background: #f3f4f6;
}

.portal-analytics__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.portal-analytics__toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.portal-analytics__toggle:hover {
    color: #1f2937;
    background: #e5e7eb;
}

.portal-analytics__toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.toggle-icon {
    transition: transform 0.2s ease;
}

.portal-analytics__content {
    padding: 1.25rem;
}

.portal-analytics__content[hidden] {
    display: none;
}

/* Empty State */
.portal-analytics__empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.portal-analytics__empty p {
    margin: 0 0 0.5rem 0;
}

.portal-analytics__empty p:last-child {
    margin-bottom: 0;
}

.portal-analytics__hint {
    font-size: 0.875rem;
    color: #9ca3af;
}

.portal-analytics__error {
    color: #dc2626;
    background: #fef2f2;
    padding: 1rem;
    border-radius: 4px;
    margin: 0;
}

/* Stat Cards */
.portal-analytics__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.portal-stat {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}

.portal-stat__value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #000032;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.portal-stat__label {
    display: block;
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* Monthly Chart */
.portal-analytics__chart {
    margin-bottom: 1.5rem;
}

.portal-analytics__subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 1rem 0;
}

.portal-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.25rem;
    height: 120px;
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem 0.5rem 0.5rem 0.5rem;
    overflow-x: auto;
}

.portal-chart__bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 40px;
    height: 100%;
}

.portal-chart__bar {
    width: 100%;
    max-width: 30px;
    background: linear-gradient(180deg, #6ACAF3 0%, #000032 100%);
    border-radius: 4px 4px 0 0;
    position: relative;
    min-height: 4px;
    transition: height 0.3s ease;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.portal-chart__bar-value {
    position: absolute;
    top: -20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #1f2937;
}

.portal-chart__label {
    font-size: 0.65rem;
    color: #6b7280;
    margin-top: 0.25rem;
    white-space: nowrap;
}

/* Breakdown Tables */
.portal-analytics__breakdowns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.portal-analytics__breakdown {
    background: #f9fafb;
    border-radius: 8px;
    padding: 1rem;
}

.portal-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.portal-breakdown-table thead th {
    text-align: left;
    font-weight: 600;
    color: #374151;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.portal-breakdown-table thead th:last-child {
    text-align: right;
}

.portal-breakdown-table tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    color: #4b5563;
}

.portal-breakdown-table tbody td:last-child {
    text-align: right;
    font-weight: 600;
    color: #1f2937;
}

.portal-breakdown-table tbody tr:last-child td {
    border-bottom: none;
}

/* Privacy Note */
.portal-analytics__privacy {
    font-size: 0.8rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.portal-analytics__privacy strong {
    color: #374151;
}

.portal-analytics__updated {
    margin: 0;
    color: #9ca3af;
    font-size: 0.75rem;
    text-align: right;
}

/* Responsive Analytics */
@media (max-width: 768px) {
    .portal-analytics__stats {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .portal-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
    }

    .portal-stat__value {
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .portal-analytics__breakdowns {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .portal-chart {
        min-width: 500px;
    }

    .portal-analytics__chart {
        overflow-x: auto;
    }
}

/* =============================================================================
   F1.8 Quota Widget (Pass 2B)
   ============================================================================= */

.portal-quota {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.portal-quota__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.portal-quota__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0c4a6e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-quota__status {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #dcfce7;
    color: #166534;
}

.portal-quota__status--warning {
    background: #fef3c7;
    color: #92400e;
}

.portal-quota__status--critical {
    background: #fee2e2;
    color: #991b1b;
}

.portal-quota__status--reached {
    background: #fecaca;
    color: #7f1d1d;
}

.portal-quota__stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.75rem;
}

.portal-quota__stat {
    flex: 1;
}

.portal-quota__stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0369a1;
    line-height: 1;
}

.portal-quota__stat-label {
    display: block;
    font-size: 0.75rem;
    color: #0c4a6e;
    margin-top: 0.15rem;
}

.portal-quota__bar {
    height: 8px;
    background: #bae6fd;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.portal-quota__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9 0%, #0369a1 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.portal-quota__bar-fill--warning {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.portal-quota__bar-fill--critical,
.portal-quota__bar-fill--reached {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

.portal-quota__trial {
    font-size: 0.8rem;
    color: #0c4a6e;
    padding-top: 0.5rem;
    border-top: 1px dashed #bae6fd;
}

.portal-quota__trial strong {
    color: #0369a1;
}

/* Quota Widget in Analytics Expanded View */
.portal-analytics--expanded .portal-quota {
    margin-top: 1rem;
}
