/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark theme colors */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --bg-card: #1e1e1e;
    --bg-input: #2d2d2d;
    --border-color: #3a3a3a;
    --border-focus: #4a90e2;
    
    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --text-accent: #4a90e2;
    
    /* Brand colors */
    --brand-primary: #af4ae2;
    --brand-secondary: #bd35b2;
    --brand-gradient: linear-gradient(170deg, #be66ea 0%, #764ba2 100%);
    
    /* Status colors */
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
    zoom: 0.75;
}

.container {
    position: relative;
    width: 100%;
    max-width: 480px;
    z-index: 10;
}

.registration-card {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

/* Header */
.header {
    padding: 40px 30px 30px;
    text-align: center;
    background: var(--brand-gradient);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.logo-image {
    width: 100%;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 400;
    margin: 0;
}

/* Form */
.form {
    padding: 40px 30px 30px;
}

.form-group {
    margin-bottom: 24px;
}

.label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
}

.input,
.select {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-family: inherit;
}

.input:focus,
.select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
    transform: translateY(-1px);
}

.input::placeholder {
    color: var(--text-tertiary);
}

.select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23808080' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.select:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%234a90e2' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

.error-message {
    display: block;
    color: var(--error-color);
    font-size: 13px;
    margin-top: 6px;
    min-height: 18px;
    font-weight: 400;
}

.submit-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: var(--brand-gradient);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-text {
    transition: opacity var(--transition-fast);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading .spinner {
    display: block;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.form-footer {
    margin-top: 24px;
    text-align: center;
}

.terms-text {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.link {
    color: var(--text-accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.link:hover {
    color: var(--brand-primary);
    text-decoration: underline;
}

/* Message container */
.message-container {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
}

.message {
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border: 1px solid;
}

.message.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
    border-color: rgba(39, 174, 96, 0.3);
}

.message.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error-color);
    border-color: rgba(231, 76, 60, 0.3);
}

.message.info {
    background: rgba(74, 144, 226, 0.1);
    color: var(--text-accent);
    border-color: rgba(74, 144, 226, 0.3);
}

/* Verification success page */
.verification-page {
    padding: 60px 30px;
    text-align: center;
}

.success-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.verification-page h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.verification-page p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.redirect-info {
    background: var(--bg-input);
    padding: 20px;
    border-radius: 12px;
    margin-top: 24px;
    border: 1px solid var(--border-color);
}

.redirect-info p {
    margin-bottom: 16px;
    font-weight: 500;
}

#redirectRegion {
    color: var(--brand-primary);
    font-weight: 600;
}

.verification-actions {
    margin-top: 24px;
}

.verification-actions .helper-text {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Account details section */
.account-details {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin: 30px 0;
    text-align: left;
}

.account-details h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    text-align: center;
}

.warning-text {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--warning-color);
    text-align: center;
}

.detail-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.detail-item label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 140px;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'Courier New', monospace;
    font-size: 15px;
}

.password-item {
    background: rgba(74, 144, 226, 0.05);
    border: 2px solid var(--brand-primary);
}

.password-display {
    display: flex;
    align-items: center;
    gap: 12px;
}

.password-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: 2px;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--brand-primary);
    transform: scale(1.1);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.error {
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.1) !important;
}

/* Background pattern */
.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(74, 144, 226, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(118, 75, 162, 0.1) 0%, transparent 50%);
    z-index: 1;
    pointer-events: none;
}

/* Responsive design */
@media (max-width: 520px) {
    .container {
        padding: 10px;
    }
    
    .registration-card {
        border-radius: 16px;
    }
    
    .header {
        padding: 30px 20px 20px;
    }
    
    .header h1 {
        font-size: 24px;
    }
    
    .logo-icon {
        font-size: 28px;
    }
    
    .form {
        padding: 30px 20px 20px;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .input,
    .select {
        padding: 12px 14px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .submit-btn {
        padding: 14px 20px;
    }
    
    .verification-page {
        padding: 40px 20px;
    }
}

@media (max-width: 380px) {
    .logo {
        flex-direction: column;
        gap: 8px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .subtitle {
        font-size: 14px;
    }
}

/* Focus styles for accessibility */
.input:focus,
.select:focus,
.submit-btn:focus,
.link:focus {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #666666;
        --text-secondary: #cccccc;
        --text-tertiary: #999999;
    }
}

/* Verification page specific styles */
.verification-loading {
    padding: 60px 30px;
    text-align: center;
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(74, 144, 226, 0.1);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

.verification-details {
    background: var(--bg-input);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
    border: 1px solid var(--border-color);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 100px;
}

.detail-item span {
    color: var(--text-primary);
    font-weight: 400;
}

.password-item {
    background: rgba(74, 144, 226, 0.05);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid rgba(74, 144, 226, 0.2);
    margin-top: 8px;
}

.password-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.password-text {
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    letter-spacing: 1px;
}

.copy-btn {
    background: none;
    border: none;
    color: var(--text-accent);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.copy-btn:hover {
    background: rgba(74, 144, 226, 0.1);
    transform: scale(1.1);
}

.error-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
}

.submit-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.submit-btn.secondary:hover {
    background: var(--bg-input);
}

/* Responsive adjustments for verification page */
@media (max-width: 520px) {
    .verification-details {
        padding: 16px;
    }
    
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .detail-item label {
        min-width: auto;
    }
    
    .password-container {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    
    .password-text {
        width: 100%;
        word-break: break-all;
    }
    
    .error-actions {
        flex-direction: column;
    }
}

/* Verification Pending UI */
.pending-container {
    animation: fadeInUp 0.5s ease;
}

.verification-pending {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    margin: 0 auto;
}

.verification-pending h2 {
    color: var(--text-primary);
    margin: 1.5rem 0 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.verification-pending p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.registration-summary {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: left;
    border: 1px solid var(--border-color);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 80px;
}

.summary-item span {
    color: var(--text-primary);
    font-weight: 500;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.pending-actions {
    margin-top: 2rem;
}

.pending-actions .submit-btn {
    margin: 0;
}

.submit-btn.secondary {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
}

.submit-btn.secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Fade in animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsiveness for pending UI */
@media (max-width: 768px) {
    .verification-pending {
        padding: 2rem 1.5rem;
        margin: 0 1rem;
    }
    
    .registration-summary {
        padding: 1rem;
    }
    
    .summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .summary-item label {
        min-width: auto;
        font-size: 0.9rem;
    }
    
    .account-details {
        padding: 16px;
        margin: 20px 0;
    }
    
    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }
    
    .detail-item label {
        min-width: auto;
        font-size: 13px;
    }
    
    .detail-value {
        font-size: 14px;
        word-break: break-all;
    }
    
    .password-value {
        font-size: 16px;
    }
    
    .password-display {
        width: 100%;
        justify-content: space-between;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner-large {
        animation: none;
        border-top-color: var(--border-color);
    }
}