@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&display=swap');

:root {
    --rootline-50: #faf8f5;
    --rootline-100: #f3efe8;
    --rootline-200: #e6ddd0;
    --rootline-300: #d4c6b0;
    --rootline-400: #bfa88c;
    --rootline-500: #a88f70;
    --rootline-600: #957a5e;
    --rootline-700: #7c644e;
    --rootline-800: #675444;
    --rootline-900: #56473b;
    --rootline-950: #2e251f;

    --surface: #ffffff;
    --surface-secondary: #faf9f7;
    --surface-tertiary: #f5f3f0;
    --border: #e8e4de;
    --border-dark: #d4cfc5;
    --text-primary: #1a1815;
    --text-secondary: #5c554a;
    --text-tertiary: #8a8279;
}

/* Override Keycloak/PatternFly defaults */
.login-pf { background: none !important; }
.login-pf body { background: none; }
.login-pf-page { all: unset; }
.card-pf { all: unset; }
.login-pf-header { all: unset; }
.pf-c-button:after { content: none; }
.pf-c-alert__icon { display: none; }

/* Reset & base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    font-family: 'Instrument Sans', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
    background: var(--surface);
}

/* ==========================================
   Two-panel layout
   ========================================== */

.login-container {
    display: flex;
    min-height: 100vh;
}

/* Left panel */
.login-left-panel {
    width: 50%;
    position: relative;
    overflow: hidden;
    display: flex;
}

.left-panel-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #a8d8ea, #d4e4f0, #f0e4d8);
}

/* Gradient blobs */
.gradient-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(48px);
    animation: pulseSoft 6s ease-in-out infinite;
}

.blob-1 {
    top: 25%;
    left: -80px;
    width: 384px;
    height: 384px;
    background: rgba(232, 196, 212, 0.6);
}

.blob-2 {
    bottom: 25%;
    right: 0;
    width: 320px;
    height: 320px;
    background: rgba(168, 216, 234, 0.5);
    animation-delay: 0.5s;
}

.blob-3 {
    top: 50%;
    left: 33%;
    width: 288px;
    height: 288px;
    background: rgba(212, 168, 196, 0.4);
    animation-delay: 0.3s;
}

@keyframes pulseSoft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Wave decoration */
.left-panel-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    color: rgba(255, 255, 255, 0.2);
    z-index: 1;
}

/* Left panel content */
.left-panel-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 32px 48px;
}

.left-panel-logo .logo-full {
    height: 24px;
    width: auto;
}

.left-panel-spacer {
    flex: 7;
}

.left-panel-copy h1 {
    font-size: 36px;
    font-weight: 600;
    color: var(--rootline-950);
    margin-bottom: 16px;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.left-panel-copy p {
    font-size: 18px;
    color: var(--rootline-700);
    line-height: 1.6;
}

/* Right panel */
.login-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 32px;
    background: var(--surface);
}

.login-right-inner {
    max-width: 448px;
    width: 100%;
    margin: auto;
}

/* Mobile logo */
.mobile-logo {
    display: none;
    margin-bottom: 32px;
}

.mobile-logo .logo-full-mobile {
    height: 28px;
    width: auto;
}

/* ==========================================
   Header / page title
   ========================================== */

.login-header {
    margin-bottom: 24px;
    width: 100%;
}

.header-section {
    margin-bottom: 32px;
}

.header-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.header-section p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

#kc-page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    margin: 0;
}

/* ==========================================
   Form elements
   ========================================== */

form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    gap: 6px;
}

.form-group-holder {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

/* Labels - visible in new design */
label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Inputs */
input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder {
    color: var(--text-tertiary);
}

input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover {
    border-color: var(--border-dark);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
    border-color: var(--rootline-400);
    box-shadow: 0 0 0 2px var(--rootline-200);
}

/* Password field wrapper */
.password-field-wrapper {
    position: relative;
    width: 100%;
}

.password-field-wrapper input {
    padding-right: 44px;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    line-height: 0;
}

.password-toggle-btn:hover {
    color: var(--text-secondary);
}

.password-toggle-btn .eye-icon,
.password-toggle-btn .eye-off-icon {
    width: 16px;
    height: 16px;
}

.password-toggle-btn .eye-off-icon {
    display: none;
}

/* Primary button */
.pf-c-button.pf-m-primary,
.btn-primary {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    background: #111827;
    color: #ffffff;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s;
    box-sizing: border-box;
    text-align: center;
}

.btn-primary:hover {
    background: #1f2937;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:focus {
    background: #1f2937;
    box-shadow: 0 0 0 2px var(--rootline-200);
    outline: none;
}

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

/* Secondary button (for SSO etc.) */
.btn-secondary {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    box-sizing: border-box;
}

.btn-secondary:hover {
    background: var(--surface-secondary);
    border-color: var(--border-dark);
}

/* Remember me + Forgot password row */
.form-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.remember-me-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
}

.remember-me-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border);
    accent-color: var(--rootline-600);
}

.forgot-password-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--rootline-700);
    text-decoration: none;
    transition: color 0.2s;
}

.forgot-password-link:hover {
    color: var(--rootline-800);
    text-decoration: none;
}

/* Social provider divider */
.social-divider {
    position: relative;
    margin: 24px 0;
    text-align: center;
}

.social-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

.social-divider span {
    position: relative;
    padding: 0 12px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 400;
    color: var(--text-tertiary);
}

/* Social provider buttons */
#kc-social-providers {
    width: 100%;
}

#kc-social-providers h4 {
    display: none;
}

.kc-social-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kc-social-links li {
    display: flex;
    width: 100%;
}

#kc-social-providers .pf-c-button {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    box-sizing: border-box;
    line-height: inherit;
}

#kc-social-providers .pf-c-button span {
    all: unset;
    font-weight: 500;
    color: var(--text-primary);
}

#kc-social-providers .pf-c-button:hover {
    background: var(--surface-secondary);
    border-color: var(--border-dark);
}

#kc-social-providers .pf-c-button:active {
    transform: scale(0.98);
}

/* ==========================================
   Alerts
   ========================================== */

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

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

.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #d97706;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #2563eb;
}

.alert-text {
    font-size: 14px;
    font-weight: 500;
    color: inherit;
}

/* Error messages on fields */
.pf-m-error {
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    margin-top: 4px;
}

#input-error {
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

#input-error-otp-code,
#input-error-username {
    color: #dc2626;
    font-size: 13px;
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

/* ==========================================
   Info page / registration link
   ========================================== */

#kc-info {
    width: 100%;
    margin-top: 32px;
    text-align: center;
}

#kc-info-wrapper {
    font-size: 14px;
    color: var(--text-tertiary);
}

#kc-info-wrapper a {
    font-weight: 500;
    color: var(--rootline-700);
    text-decoration: none;
}

#kc-info-wrapper a:hover {
    color: var(--rootline-800);
}

#kc-info-wrapper span {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-tertiary);
}

/* ==========================================
   OTP page
   ========================================== */

.otp-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 16px;
    text-align: center;
}

#kc-otp-login-form {
    padding-top: 0;
}

#kc-otp-login-form .form-group > div {
    padding: 0;
    margin-bottom: 4px;
}

/* ==========================================
   TOTP config page
   ========================================== */

#kc-totp-settings {
    font-size: 14px;
    color: var(--text-secondary);
    padding-left: 20px;
    margin-bottom: 24px;
}

#kc-totp-settings * {
    font-size: 14px;
    color: var(--text-secondary);
}

#kc-totp-settings > li {
    margin-bottom: 16px;
}

#kc-totp-supported-apps li {
    color: var(--text-primary);
}

#kc-totp-settings-form label {
    display: inline-block;
}

#kc-totp-settings-form .form-group {
    all: unset;
    width: 100%;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#kc-totp-settings-form .form-group > div {
    padding: 0;
}

#kc-totp-settings-form #logout-sessions {
    position: relative;
    width: 20px;
}

#kc-totp-settings-form #kc-form-options .checkbox label {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 8px;
}

/* ==========================================
   Update password page
   ========================================== */

.update-password-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.update-password-header .header-icon {
    color: var(--text-primary);
}

.update-password-header .header-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==========================================
   Info page
   ========================================== */

.info-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

.info-header .header-icon {
    width: 36px;
    height: 36px;
}

.info-header .header-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

#kc-info-message {
    width: 100%;
    display: flex;
    gap: 16px;
    flex-direction: column;
}

#kc-info-message p {
    font-size: 16px;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    line-height: 1.5;
    text-align: center;
    color: var(--text-secondary);
}

#kc-info-message a {
    text-decoration: none;
}

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

.instruction a {
    text-decoration: underline;
    color: var(--text-primary);
}

/* ==========================================
   Reset password
   ========================================== */

#kc-reset-password-form #kc-form-options {
    display: none;
}

#kc-reset-password-form .form-group {
    margin-bottom: 8px;
}

/* ==========================================
   Username display (for OTP after login)
   ========================================== */

.kc-username-display {
    margin-bottom: 8px;
}

.kc-username-display label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

#reset-login {
    display: none;
}

.kc-login-tooltip {
    display: inline;
}

.kc-login-tooltip .pficon {
    display: none;
}

.kc-login-tooltip .kc-tooltip-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ==========================================
   General typography overrides
   ========================================== */

span {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Instrument Sans', system-ui, sans-serif;
    color: var(--text-primary);
}

h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-align: center;
    padding: 0;
    margin: 0;
}

a {
    color: var(--rootline-700);
    text-decoration: none;
}

a:hover {
    color: var(--rootline-800);
}

/* Required field marker */
.required {
    color: #dc2626;
}

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

@media (max-width: 1023px) {
    .login-left-panel {
        display: none;
    }

    .mobile-logo {
        display: block;
    }

    .login-right-panel {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .login-right-panel {
        padding: 16px;
    }

}

/* ==========================================
   Misc overrides for Keycloak parent theme
   ========================================== */

#kc-content {
    width: 100%;
}

#kc-content-wrapper {
    width: 100%;
}

#kc-form-buttons {
    width: 100%;
}

#kc-form-buttons input[type="submit"] {
    width: 100%;
    padding: 10px 20px;
    background: #111827;
    color: #ffffff;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Instrument Sans', system-ui, sans-serif;
    cursor: pointer;
    transition: background-color 0.2s;
    border: none;
}

#kc-form-buttons input[type="submit"]:hover {
    background: #1f2937;
}

/* Locale dropdown styling */
.locale-dropdown {
    margin-bottom: 16px;
}

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

.locale-list {
    list-style: none;
    padding: 8px 0;
    margin: 4px 0 0 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.locale-list li a {
    display: block;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-primary);
}

.locale-list li a:hover {
    background: var(--surface-secondary);
}

#kc-error-message {
    text-align: center;
}
