/**
 * PORTAL-SPECIFIC STYLES
 * Clean, focused styling for authentication pages
 * Uses main site color variables for consistent theming
 */

/* Portal page layout with theme support */
.portal-page {
    /* Force proper theme variable inheritance */
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: 'Spectral', serif;
    padding-top: 160px; /* Increased to move register form farther down */
}

/* Ensure instant theme switching - no transitions on theme properties */
.portal-page *,
.portal-page *::before,
.portal-page *::after {
    transition-property: transform, opacity, visibility, box-shadow, margin, padding, width, height, top, left, right, bottom, z-index, font-size, font-weight, text-decoration !important;
}

/* Portal main content - no hero, just centered form */
.portal-main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: calc(100vh - 160px); /* Updated to match new padding-top */
    box-sizing: border-box;
}

/* Portal dashboard main content - full width layout */
.portal-payment .portal-main-content {
    align-items: flex-start;
    justify-content: stretch;
    padding: 1rem 0;
}

/* Portal form container */
.portal-form-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 450px;
    margin: 1rem auto;
    box-shadow: 0 4px 20px var(--shadow);
    box-sizing: border-box;
}

/* Portal form header */
.portal-form-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.portal-form-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: 'Spectral', serif;
}

.portal-form-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.6;
}

/* Portal form styles */
.portal-form {
    width: 100%;
}

.portal-form .form-group {
    margin-bottom: 1.5rem;
}

.portal-form label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-family: 'Spectral', serif;
}

.portal-form input[type="text"],
.portal-form input[type="email"],
.portal-form input[type="password"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Spectral', serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.portal-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

[data-theme="dark"] .portal-form input:focus {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
}

[data-theme="light"] .portal-form input:focus {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}

.portal-form input.readonly {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Two-column form row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Form actions */
.portal-form .form-actions {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.portal-form .btn {
    padding: 0.875rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    display: inline-block;
    font-family: 'Spectral', serif;
}

.portal-form .btn-primary {
    background: var(--accent);
    color: white;
}

.portal-form .btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

[data-theme="light"] .portal-form .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.portal-form .btn-link {
    background: transparent;
    color: var(--accent);
    font-weight: 400;
    padding: 0.5rem;
}

.portal-form .btn-link:hover {
    text-decoration: underline;
}

.portal-form .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.portal-form .btn-secondary:hover {
    background: var(--border);
}

/* Checkbox group */
.checkbox-group {
    margin: 1.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.4;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    width: auto;
    flex-shrink: 0;
    margin-top: 0.1rem;
    accent-color: var(--accent);
}

/* Ensure checkbox visibility in both themes */
[data-theme="dark"] .checkbox-label input[type="checkbox"] {
    filter: brightness(1.1);
}

[data-theme="light"] .checkbox-label input[type="checkbox"] {
    filter: brightness(0.9);
}

/* Portal form footer */
.portal-form-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.portal-form-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    font-family: 'Spectral', serif;
}

.portal-form-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.portal-form-footer a:hover {
    text-decoration: underline;
}

.home-link {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.home-link:hover {
    color: var(--accent);
}

/* Portal link styling - ensures content links match site design (excludes navigation) */
.portal-main-content a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.portal-main-content a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.portal-main-content a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Specific styling for form links */
.portal-form a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.portal-form a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Links in info sections */
.portal-info a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.portal-info a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* External link styling */
.portal-main-content a[target="_blank"] {
    color: var(--accent);
}

.portal-main-content a[target="_blank"]:hover {
    color: var(--accent-hover);
}

/* Alert messages */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-family: 'Spectral', serif;
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid var(--success);
    color: var(--text-primary);
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--text-primary);
}

/* Ensure alerts are visible in both themes */
[data-theme="dark"] .alert-success {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
}

[data-theme="dark"] .alert-error {
    background: rgba(244, 67, 54, 0.15);
    border-color: rgba(244, 67, 54, 0.3);
}

[data-theme="light"] .alert-success {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.25);
}

[data-theme="light"] .alert-error {
    background: rgba(244, 67, 54, 0.1);
    border-color: rgba(244, 67, 54, 0.25);
}

.alert p {
    margin: 0;
}

.alert p:not(:last-child) {
    margin-bottom: 0.5rem;
}

/* Small helper text */
.portal-form small {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.25rem;
    font-family: 'Spectral', serif;
}

/* Portal dashboard (payment page) */
.portal-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem 2rem;
    width: 100%;
}

.dashboard-container {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 3rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .dashboard-container {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.05);
}

.dashboard-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-header h2 {
    color: var(--text-primary);
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
    font-family: 'Spectral', serif;
}

.account-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    padding: 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.dashboard-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    max-width: none;
}

/* Desktop-specific grid improvements */
@media (min-width: 1200px) {
    .dashboard-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 2.5rem;
    }
}

@media (min-width: 1600px) {
    .dashboard-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 2.5rem;
    }
}

.dashboard-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
    transform-origin: left;
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px var(--shadow);
    border-color: var(--accent);
}

.dashboard-card:hover::before {
    transform: scaleX(1);
}

[data-theme="dark"] .dashboard-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .dashboard-card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.dashboard-card h3 {
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-size: 1.3rem;
    font-weight: 600;
    font-family: 'Spectral', serif;
}

.dashboard-card p {
    color: var(--text-secondary);
    margin: 0 0 2rem 0;
    font-size: 1rem;
    line-height: 1.6;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .portal-page {
        padding-top: 140px; /* Increased to move form farther down on mobile */
    }
    
    .portal-main-content {
        padding: 1.5rem 1rem;
        min-height: calc(100vh - 80px);
    }
    
    .portal-form-container {
        padding: 2rem 1.5rem;
        margin: 0.75rem;
        max-width: none;
    }
    
    .portal-form-header {
        margin-bottom: 1.5rem;
    }
    
    .portal-form-header h1 {
        font-size: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .portal-form .form-group {
        margin-bottom: 1.25rem;
    }
    
    .portal-form-footer {
        margin-top: 1.25rem;
        padding-top: 1rem;
    }
    
    .portal-payment .portal-main-content {
        padding: 1rem 0;
    }
    
    .portal-dashboard {
        padding: 1rem;
    }
    
    .dashboard-container {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .dashboard-header h2 {
        font-size: 1.5rem;
    }
    
    .account-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
        margin-bottom: 2rem;
    }
    
    .dashboard-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .dashboard-card {
        padding: 1.5rem;
    }
    
    .dashboard-card h3 {
        font-size: 1.1rem;
    }
    
    .dashboard-card p {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .portal-page {
        padding-top: 130px; /* Increased to move form farther down on small mobile */
    }
    
    .portal-main-content {
        padding: 1rem 0.5rem;
        min-height: calc(100vh - 70px);
    }
    
    .portal-payment .portal-main-content {
        padding: 0.5rem 0;
    }
    
    .portal-dashboard {
        padding: 0.5rem;
    }
    
    .dashboard-container {
        padding: 1rem;
    }
    
    .portal-form-container {
        padding: 1.5rem 1rem;
        margin: 0.5rem;
        border-radius: 8px;
    }
    
    .portal-form-header {
        margin-bottom: 1.25rem;
    }
    
    .portal-form-header h1 {
        font-size: 1.375rem;
    }
    
    .portal-form .form-group {
        margin-bottom: 1rem;
    }
    
    .portal-form .form-actions {
        margin-top: 1.5rem;
    }
    
    .portal-form-footer {
        margin-top: 1rem;
        padding-top: 0.75rem;
    }
}

/* Ensure forms fit on shorter screens */
@media (max-height: 700px) {
    .portal-main-content {
        align-items: flex-start;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .portal-form-container {
        margin: 0.5rem auto;
    }
}

@media (max-height: 600px) {
    .portal-form-container {
        padding: 1.5rem;
    }
    
    .portal-form-header {
        margin-bottom: 1rem;
    }
    
    .portal-form .form-group {
        margin-bottom: 1rem;
    }
    
    .portal-form-footer {
        margin-top: 1rem;
        padding-top: 0.75rem;
    }
}

/* ========================================
   PORTAL GLOBAL BUTTON STYLES
   Consistent with main site CTA buttons
   ======================================== */

/* Base button style for portal (outside of forms) */
.portal-dashboard .btn,
.account-info .btn,
.dashboard-card .btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    text-align: center;
    font-family: 'Spectral', serif;
}

/* Primary button - matches main site cta-button.primary */
.portal-dashboard .btn-primary,
.account-info .btn-primary,
.dashboard-card .btn-primary {
    background: var(--accent);
    color: white;
    border: 2px solid var(--accent);
}

.portal-dashboard .btn-primary:hover,
.account-info .btn-primary:hover,
.dashboard-card .btn-primary:hover {
    background: transparent;
    color: var(--accent);
}

/* Secondary button - matches main site cta-button.secondary */
.portal-dashboard .btn-secondary,
.account-info .btn-secondary,
.dashboard-card .btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.portal-dashboard .btn-secondary:hover,
.account-info .btn-secondary:hover,
.dashboard-card .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-primary);
}

/* Light theme adjustments */
[data-theme="light"] .portal-dashboard .btn-secondary,
[data-theme="light"] .account-info .btn-secondary,
[data-theme="light"] .dashboard-card .btn-secondary {
    color: var(--text-primary);
    border-color: var(--border);
}

[data-theme="light"] .portal-dashboard .btn-secondary:hover,
[data-theme="light"] .account-info .btn-secondary:hover,
[data-theme="light"] .dashboard-card .btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-primary);
}

/* Smaller button variant for account info area */
.portal-dashboard .btn-small,
.account-info .btn-small,
.dashboard-card .btn-small {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Logout link styling */
.account-info .logout-link {
    color: var(--error);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.account-info .logout-link:hover {
    color: var(--error-hover);
    text-decoration: underline;
}