/**
 * DAVis AI - Keycloak Login Theme Styles
 * Modern, clean authentication UI
 */

/* ===================================
   CSS Variables / Design Tokens
   =================================== */
:root {
    /* Colors - Light Theme */
    --bg-primary: #F3F6FB;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #eef1f5;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    /* Brand Colors */
    --accent-primary: #5d72de;
    --accent-secondary: #3d52ba;
    --accent-tint: rgba(93, 114, 222, 0.1);
    
    /* Semantic Colors */
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    
    /* Borders & Shadows */
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Button Colors */
    --btn-primary-bg: var(--accent-primary);
    --btn-primary-hover: var(--accent-secondary);
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #f3f4f6;
    --hover-bg: #e5e7eb;
    
    /* Spacing & Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    /* Typography */
    --font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Dark Theme Support */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --accent-primary: #3d52ba;
    --accent-secondary: #5d72de;
    --border-color: #475569;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --btn-primary-bg: var(--accent-primary);
    --btn-primary-hover: #5d72de;
    --btn-secondary-bg: var(--bg-tertiary);
    --hover-bg: var(--border-color);
}

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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-primary);
    background: var(--bg-primary) !important;
    background-image: none !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* ===================================
   Layout Components
   =================================== */
.auth-wrapper,
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 32px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ===================================
   Header & Logo
   =================================== */
.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.logo,
.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.logo-main,
#kc-logo {
    width: 180px;
    height: auto;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    object-fit: contain;
}

.auth-title {
    margin: 8px 0 4px;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 600;
    color: var(--text-primary);
}

#signin-title,
#signup-title,
#update-password-title {
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.auth-subtitle {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

/* ===================================
   Form Styles
   =================================== */
.auth-form {
    display: grid;
    gap: 16px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ===================================
   Input Fields
   =================================== */
input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px 12px;
    font-size: 14px;
    font-family: var(--font-family);
    outline: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

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

input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-tint);
}

/* Input with icon wrapper */
.input-wrap {
    position: relative;
}

.input-wrap input {
    padding-right: 44px;
}

/* ===================================
   Password Toggle Button
   =================================== */
.show-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: color 150ms ease, background 150ms ease;
}

.show-toggle:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.show-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ===================================
   Buttons
   =================================== */
.btn-primary {
    height: 44px;
    width: 100%;
    border: 1px solid var(--btn-primary-bg);
    border-radius: var(--radius-md);
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 100ms ease, box-shadow 150ms ease, background 150ms ease;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Force button colors in all states */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
#kc-login.btn-primary,
#kc-login.btn-primary:hover,
#kc-login.btn-primary:focus,
#kc-login.btn-primary:active {
    background: var(--accent-secondary) !important;
    background-color: var(--accent-secondary) !important;
    background-image: none !important;
    border-color: var(--accent-secondary) !important;
}

.btn-secondary {
    height: 44px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--btn-secondary-bg);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    margin-top: 8px;
    transition: background 150ms ease, border-color 150ms ease;
}

.btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary);
}

/* Social Login Buttons */
.social-row {
    display: block;
    margin-bottom: 8px;
}

.btn-social {
    height: 44px;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px 0 44px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color 150ms ease, background 150ms ease;
}

.btn-social:hover {
    border-color: var(--accent-primary);
    background: var(--hover-bg);
}

.social-ico {
    position: absolute;
    left: 12px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-primary);
    color: var(--btn-primary-text);
    font-size: 12px;
    font-weight: 700;
}

.social-text {
    font-size: 14px;
    font-weight: 600;
}

/* ===================================
   Meta Row (Remember Me + Forgot Password)
   =================================== */
.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: -4px;
}

.remember {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    accent-color: var(--accent-primary);
}

.link-muted {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: color 150ms ease;
}

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

/* ===================================
   Divider
   =================================== */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

/* ===================================
   Form Options (Sign Up Link)
   =================================== */
.kc-form-options {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.signup-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.signup-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 150ms ease;
}

.signup-link:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* ===================================
   Password Requirements
   =================================== */
.password-requirements {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 8px 0 16px;
}

.requirements-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px;
}

.requirements-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.requirements-list li {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 200ms ease;
}

.requirements-list li .req-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    color: var(--text-muted);
    transition: color 200ms ease;
}

.requirements-list li.met {
    color: var(--success-color);
}

.requirements-list li.met .req-icon {
    color: var(--success-color);
    font-weight: 600;
}

/* ===================================
   Alerts / Messages
   =================================== */
.alert-warning,
.alert-error,
.alert-success,
.alert-info {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 300ms ease, transform 300ms ease;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #b45309;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.alert-success {
    background: #10b981;
    border: 1px solid #059669;
    color: #ffffff !important;
}

.alert-info {
    background: var(--accent-tint);
    border: 1px solid rgba(93, 114, 222, 0.3);
    color: var(--accent-primary);
}

/* ===================================
   Error States
   =================================== */
.error-text,
#input-error,
.pf-c-form__helper-text.pf-m-error,
.alert-error .kc-feedback-text {
    color: var(--error-color) !important;
    font-size: 12px;
    margin-top: 4px;
}

/* Alert text colors - inherit from parent */
.alert-success .kc-feedback-text,
.alert-warning .kc-feedback-text,
.alert-info .kc-feedback-text {
    color: inherit !important;
}

/* Remove PatternFly validation icons */
.pf-c-form-control::before,
.pf-c-form-control::after,
.pf-m-error::before,
.pf-m-error::after {
    display: none !important;
}

/* Error input styling - ONLY when aria-invalid is explicitly true */
input[aria-invalid="true"],
input.pf-m-error,
.has-error input,
.pf-c-form-control.pf-m-error {
    background: var(--bg-secondary) none !important;
    background-image: none !important;
    border-color: var(--error-color) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08) !important;
}

/* Reset styles for empty required fields - prevent red borders on initial load */
input:invalid:not([aria-invalid="true"]),
input:required:not([aria-invalid="true"]):placeholder-shown {
    border-color: var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
}

/* Normal input state */
input:not([aria-invalid="true"]):not(.pf-m-error) {
    border-color: var(--border-color);
}

/* ===================================
   Footer
   =================================== */
.auth-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

.foot-note {
    margin: 0;
}

/* ===================================
   Keycloak Overrides
   =================================== */
.login-pf-page {
    padding-top: 0 !important;
}

.login-pf-page .btn-primary {
    margin-top: 12px !important;
}

#kc-container,
#kc-content,
#kc-content-wrapper {
    background: transparent !important;
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 480px) {
    .auth-wrapper,
    .auth-shell {
        padding: 16px;
    }
    
    .auth-card {
        padding: 24px;
        border-radius: var(--radius-md);
    }
    
    .auth-title {
        font-size: 20px;
    }
    
    .meta-row {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}
