/* REV23 IdentityServer - Dark Background with Light Card */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */
:root {
    /* Background (dark with orbs) */
    --bg-dark: #1a1625;

    /* Card (light mode) */
    --bg-card: #ffffff;
    --bg-surface: #f8f9fa;
    --border-color: #e2e8f0;
    --border-color-dark: #cbd5e1;

    /* Text (dark for light card) */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Accent Colors */
    --accent-blue: #0891b2;
    --accent-blue-light: #06b6d4;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    --accent-red: #ef4444;

    /* Gradients */
    --gradient-glow: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-purple) 100%);

    /* Form Elements (light mode) */
    --input-bg: #ffffff;
    --input-border: #e2e8f0;
    --input-focus-border: var(--accent-blue);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Colorful gradient orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
}

body::before {
    top: -15%;
    right: -10%;
    width: 45%;
    height: 45%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, rgba(236, 72, 153, 0.2) 50%, transparent 70%);
    animation: floatOrb1 15s ease-in-out infinite;
}

body::after {
    bottom: -15%;
    left: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.35) 0%, rgba(99, 102, 241, 0.2) 50%, transparent 70%);
    animation: floatOrb2 18s ease-in-out infinite;
}

@keyframes floatOrb1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-5%, 5%) scale(1.1); }
}

@keyframes floatOrb2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(5%, -5%) scale(1.05); }
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--accent-purple);
}

/* ==========================================================================
   Layout
   ========================================================================== */
.main-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.auth-card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    max-width: 400px;
    padding: 2.5rem 2rem;
    width: 100%;
    position: relative;
}

/* ==========================================================================
   Header / Branding
   ========================================================================== */
.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header .tenant-logo {
    max-height: 80px;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
}

.auth-header .tenant-name {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.auth-header .app-name {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
}

/* ==========================================================================
   Page Titles
   ========================================================================== */
.page-title {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    text-align: center;
    letter-spacing: -0.02em;
}

.page-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin-bottom: 1.25rem;
}

.page-description.text-center {
    text-align: center;
}

/* ==========================================================================
   Login Page - Dual Section Layout
   ========================================================================== */

/* REV23 ID Button - The Star */
.btn-rev23-id {
    background: var(--gradient-glow);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px rgba(8, 145, 178, 0.3);
    box-sizing: border-box;
    color: #ffffff;
    display: block;
    font-size: 1.0625rem;
    font-weight: 700;
    max-width: 100%;
    padding: 1rem 1.5rem;
    position: relative;
    text-align: center;
    transition: all 0.3s ease;
    width: 100%;
    overflow: hidden;
}

.btn-rev23-id:hover {
    color: #ffffff;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(8, 145, 178, 0.4), 0 0 0 4px rgba(139, 92, 246, 0.1);
}

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

.btn-rev23-id i {
    margin-right: 0.5rem;
}

.rev23-id-section {
    margin-bottom: 1.5rem;
}

.rev23-id-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.75rem;
    text-align: center;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--border-color), var(--border-color-dark));
}

.auth-divider span {
    padding: 0 1rem;
    background: var(--bg-card);
}

/* Local Login Section */
.local-login-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
}

.local-login-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-purple), var(--accent-blue), transparent);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.local-login-header {
    color: var(--text-secondary);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.local-login-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */
.form-control {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    font-size: 0.9375rem !important;
    padding: 0.75rem 1rem !important;
    transition: all 0.2s ease;
    width: 100%;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-control:focus {
    background: var(--input-bg) !important;
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.15) !important;
    color: var(--text-primary) !important;
    outline: none;
}

/* Input styling within local login section */
.local-login-section .form-control {
    background: #ffffff !important;
    border: 1px solid #d1d5db !important;
}

.local-login-section .form-control:focus {
    background: #ffffff !important;
    border-color: var(--accent-blue) !important;
}

.form-group {
    margin-bottom: 0.875rem;
}

label {
    color: var(--text-secondary);
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

/* Custom Checkbox */
.form-check {
    display: flex;
    align-items: center;
    padding-left: 0;
}

.form-check-input {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff !important;
    border: 2px solid #d1d5db !important;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    float: none !important;
    height: 18px !important;
    margin: 0 0.5rem 0 0 !important;
    position: relative;
    transition: all 0.2s ease;
    width: 18px !important;
}

.form-check-input:checked {
    background-color: var(--accent-purple) !important;
    border-color: var(--accent-purple) !important;
}

.form-check-input:checked::before {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: bold;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.form-check-label {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    border-radius: var(--radius-sm) !important;
    cursor: pointer;
    font-size: 0.9375rem !important;
    font-weight: 600;
    padding: 0.75rem 1.25rem !important;
    text-align: center;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--accent-purple) !important;
    border: none !important;
    color: #ffffff !important;
}

.btn-primary:hover {
    background: #7c3aed !important;
    color: #ffffff !important;
}

.btn-secondary {
    background: transparent !important;
    border: 1px solid var(--border-color-dark) !important;
    color: var(--text-secondary) !important;
}

.btn-secondary:hover {
    background: var(--bg-surface) !important;
    border-color: var(--text-primary) !important;
    color: var(--text-primary) !important;
}

.btn-block {
    display: block;
    width: 100%;
}

/* ==========================================================================
   Form Utilities
   ========================================================================== */
.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-link {
    color: var(--accent-blue);
    font-size: 0.8125rem;
    white-space: nowrap;
}

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

@media (max-width: 360px) {
    .form-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ==========================================================================
   Alerts / Validation
   ========================================================================== */
.alert {
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    padding: 0.875rem 1rem;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-danger .alert-icon {
    color: var(--accent-red);
    margin-right: 0.5rem;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
}

/* Field Validation - Inline errors */
.form-control.input-validation-error {
    border-color: var(--accent-red) !important;
    background-color: #fef2f2 !important;
}

.form-control.input-validation-error:focus {
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15) !important;
}

.field-validation-error {
    color: var(--accent-red);
    font-size: 0.8125rem;
    display: block;
    margin-top: 0.375rem;
}

.field-validation-valid {
    display: none;
}

/* Model-level login error */
.login-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-red);
    font-size: 0.8125rem;
    margin-bottom: 0.5rem;
}

.login-error i {
    flex-shrink: 0;
}

/* Login hint (e.g., REV23 ID suggestion) */
.login-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-purple);
    font-size: 0.8125rem;
    margin-bottom: 1rem;
}

.login-hint i {
    flex-shrink: 0;
    color: #eab308;
}

/* Summary validation (fallback) */
.validation-errors,
.validation-summary-errors {
    margin-bottom: 1rem;
}

.validation-errors ul,
.validation-summary-errors ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.validation-errors li,
.validation-summary-errors li {
    color: var(--accent-red);
    font-size: 0.8125rem;
    padding: 0.25rem 0;
}

/* ==========================================================================
   Cards (for Consent page etc.)
   ========================================================================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.875rem;
    overflow: hidden;
}

.card-header {
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.875rem 1rem;
}

.card-header i {
    color: var(--accent-blue);
    margin-right: 0.5rem;
}

.card-body {
    padding: 1rem;
}

.list-group {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-group-item {
    background: #ffffff;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.875rem 1rem;
}

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

.list-group-item label {
    color: var(--text-primary);
    display: inline;
    margin-bottom: 0;
}

.consent-description {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
    padding-left: 1.625rem;
}

.consent-description label {
    color: var(--text-muted);
}

/* Consent Page Header */
.consent-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.consent-app-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex-shrink: 0;
}

.consent-app-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-purple);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.consent-header-text {
    flex: 1;
    min-width: 0;
}

.consent-header-text .page-title {
    text-align: left;
    margin-bottom: 0.125rem;
    font-size: 1.125rem;
}

.consent-header-text .page-description {
    text-align: left;
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ==========================================================================
   Error/Status Pages
   ========================================================================== */
.status-page {
    text-align: center;
}

.status-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--accent-purple);
}

.status-icon.success {
    color: var(--accent-green);
}

.status-icon.error {
    color: var(--accent-red);
}

.status-icon.warning {
    color: #f59e0b;
}

/* Button with icon */
.btn i {
    margin-right: 0.5rem;
}

/* Info Callout */
.info-callout {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 1.5rem;
    font-size: 0.8125rem;
    color: #0369a1;
}

.info-callout > i {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.info-callout strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #0c4a6e;
}

.info-callout a {
    color: #0369a1;
    text-decoration: underline;
}

.info-callout a:hover {
    color: #0c4a6e;
}

/* Back Link */
.back-link {
    color: var(--text-muted);
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--text-primary);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.875rem; }
.mb-4 { margin-bottom: 1.25rem; }
.mb-5 { margin-bottom: 1.5rem; }

.mt-3 { margin-top: 0.875rem; }
.mt-4 { margin-top: 1.25rem; }

.pt-3 { padding-top: 0.875rem; }

.small { font-size: 0.8125rem; }
.font-weight-bold { font-weight: 600; }

.gap-2 { gap: 0.5rem; }
.flex-fill { flex: 1 1 auto; }
.d-flex { display: flex; }

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 576px) {
    body::before,
    body::after {
        animation: none;
    }

    .main-container {
        padding: 1rem;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }

    .local-login-section {
        padding: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after {
        animation: none;
    }
}

/* ==========================================================================
   Focus States for Accessibility
   ========================================================================== */
.btn:focus,
a:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.btn:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* Override Bootstrap focus-visible box-shadow */
.form-control:focus-visible {
    box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.15) !important;
}
