/* =====================================================
   FCBU System - Login Page Stylesheet
   Fellowship of Christian Believers Uganda
   Centered Card Design
   ===================================================== */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
    /* FCBU Brand Colors - Premium Forest Teal & Warm Gold Palette */
    --primary: #063733;
    --primary-dark: #03211E;
    --primary-light: #0C544E;
    --primary-rgb: 6, 55, 51;

    --accent-gold: #CBA154;
    --accent-red: #D9534F;

    /* Neutrals */
    --bg: #E6ECEB;
    --card-bg: #ffffff;
    --input-bg: #F0F4F3;
    --input-border: #D1DAD8;
    --input-focus-border: var(--primary);
    --text-dark: #132B29;
    --text-body: #3A4E4C;
    --text-muted: #7E908E;
    --text-label: #2D3E3C;

    /* Shadows */
    --card-shadow: 0 12px 40px rgba(6, 55, 51, 0.08), 0 2px 10px rgba(6, 55, 51, 0.04);
    --btn-shadow: 0 4px 15px rgba(6, 55, 51, 0.35);
    --btn-hover-shadow: 0 6px 25px rgba(6, 55, 51, 0.45);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 50px;
    --radius-full: 50%;

    /* Transitions */
    --transition: 250ms ease;
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    overflow-y: auto; /* Enabled vertical scrolling on short screens */
}

form {
    height: 100%;
}

/* ---------- Background Decoration ---------- */
.login-page {
    position: relative;
    display: flex;
    flex-direction: column; /* Center card and stack footer */
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    padding: 30px 20px; /* Breathing room on top/bottom */
    overflow-y: auto;
}

/* Floating decorative elements */
.bg-decoration {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.bg-blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    filter: blur(110px);
}

.bg-blob:nth-child(1) {
    width: 260px; height: 260px;
    background: var(--primary);
    top: -5%; left: -5%;
    animation: float1 25s ease-in-out infinite;
}
.bg-blob:nth-child(2) {
    width: 220px; height: 220px;
    background: var(--accent-gold);
    top: 8%; right: -5%;
    animation: float2 22s ease-in-out infinite;
}
.bg-blob:nth-child(3) {
    width: 320px; height: 320px;
    background: var(--primary-light);
    bottom: -8%; left: -8%;
    animation: float3 28s ease-in-out infinite;
}
.bg-blob:nth-child(4) {
    width: 160px; height: 160px;
    background: var(--accent-gold);
    top: 35%; left: 15%;
    opacity: 0.08;
    animation: float4 18s ease-in-out infinite;
}
.bg-blob:nth-child(5) {
    width: 240px; height: 240px;
    background: var(--primary);
    bottom: 5%; right: -5%;
    animation: float1 20s ease-in-out infinite reverse;
}
.bg-blob:nth-child(6) {
    width: 150px; height: 150px;
    background: var(--accent-gold);
    top: 55%; left: -5%;
    opacity: 0.08;
    animation: float2 15s ease-in-out infinite;
}
.bg-blob:nth-child(7) {
    width: 180px; height: 180px;
    background: var(--primary-light);
    top: -8%; right: 25%;
    animation: float3 16s ease-in-out infinite;
}
.bg-blob:nth-child(8) {
    width: 230px; height: 230px;
    background: var(--primary);
    bottom: -5%; right: 20%;
    animation: float4 24s ease-in-out infinite;
}
.bg-blob:nth-child(9) {
    width: 140px; height: 140px;
    background: var(--accent-gold);
    top: 40%; right: -5%;
    animation: float1 12s ease-in-out infinite;
}
.bg-blob:nth-child(10) {
    width: 280px; height: 280px;
    background: var(--primary-light);
    bottom: 30%; left: 25%;
    opacity: 0.07;
    animation: float2 26s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(15px, -20px) rotate(5deg); }
    66% { transform: translate(-10px, 15px) rotate(-3deg); }
}
@keyframes float2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-20px, -15px) scale(1.1); }
}
@keyframes float3 {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(10px, 20px); }
    75% { transform: translate(-15px, -10px); }
}
@keyframes float4 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(20px, 10px) rotate(8deg); }
}

/* ---------- Login Card ---------- */
.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: 36px 30px 28px;
    text-align: center;
    animation: cardEntry 0.5s ease-out;
    margin: auto; /* Perfect vertical & horizontal centering in flex flow */
}

@keyframes cardEntry {
    0% { opacity: 0; transform: translateY(25px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Staff Portal Badge ---------- */
.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(203, 161, 84, 0.1);
    color: var(--accent-gold);
    border: 1px solid rgba(203, 161, 84, 0.2);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    margin-bottom: 12px;
}

.portal-badge svg {
    width: 11px;
    height: 11px;
}

/* ---------- Logo Circle ---------- */
.logo-circle {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-full);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    box-shadow: 0 4px 12px rgba(6, 55, 51, 0.08);
    border: 2px solid #E6ECEB;
}

.logo-circle img {
    width: 66px;
    height: 66px;
    object-fit: contain;
    transition: transform var(--transition);
}

.logo-circle:hover img {
    transform: scale(1.05);
}

/* ---------- Card Header ---------- */
.card-header h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.card-header .subtitle {
    font-size: 0.88rem;
    color: var(--primary);
    font-weight: 500;
    margin-bottom: 6px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 24px;
    transition: color var(--transition);
}

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

.back-link svg {
    width: 14px;
    height: 14px;
}

/* ---------- Form Fields ---------- */
.field-group {
    text-align: left;
    margin-bottom: 18px;
}

.field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-label);
    margin-bottom: 6px;
}

.field-label svg {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

.field-wrapper {
    position: relative;
}

.field-wrapper input[type="text"],
.field-wrapper input[type="password"] {
    width: 100%;
    padding: 13px 16px;
    background: var(--input-bg);
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    font-weight: 400;
    outline: none;
    transition: all var(--transition);
}

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

.field-wrapper input:focus {
    border-color: var(--input-focus-border);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.08);
}

/* Password toggle */
.pwd-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
    z-index: 1;
}

.pwd-toggle:hover {
    color: var(--text-body);
}

.pwd-toggle svg {
    width: 18px;
    height: 18px;
}

/* ---------- Options Row ---------- */
.options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}

.remember-check {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.remember-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
    margin: 0;
}

.remember-check span {
    font-size: 0.82rem;
    color: var(--text-muted);
    user-select: none;
}

.forgot-link {
    font-size: 0.82rem;
    color: var(--accent-gold);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition);
}

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

/* ---------- Login Button ---------- */
.btn-login {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gold);
    color: var(--primary);
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 4px 15px rgba(203, 161, 84, 0.25);
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.btn-login::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.4s ease;
}

.btn-login:hover {
    background: var(--primary);
    color: var(--accent-gold);
    box-shadow: var(--btn-hover-shadow);
    transform: translateY(-1px);
}

.btn-login:hover::after {
    left: 100%;
}

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

/* Loading state */
.btn-login.loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

.btn-login.loading + .btn-spinner {
    display: inline-block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- SSL Badge ---------- */
.ssl-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 22px;
    padding: 8px 18px;
    background: rgba(6, 55, 51, 0.03);
    border: 1px solid rgba(203, 161, 84, 0.25);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.01em;
}

.ssl-badge svg {
    width: 15px;
    height: 15px;
    color: var(--accent-gold);
}

/* ---------- Error Message ---------- */
.error-box {
    display: none;
    align-items: center;
    gap: 8px;
    text-align: left;
    padding: 11px 14px;
    margin-bottom: 18px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
}

.error-box.visible {
    display: flex;
    animation: shakeIn 0.45s ease-out;
}

.error-box svg {
    width: 18px;
    height: 18px;
    color: #dc2626;
    flex-shrink: 0;
}

.error-box .error-msg {
    font-size: 0.82rem;
    color: #dc2626;
    font-weight: 500;
    line-height: 1.4;
}

@keyframes shakeIn {
    0% { opacity: 0; transform: translateX(-8px); }
    25% { transform: translateX(6px); }
    50% { transform: translateX(-4px); }
    75% { transform: translateX(2px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ---------- Copyright Footer ---------- */
.page-footer {
    text-align: center;
    z-index: 1;
    margin-top: auto; /* Allow pushing to bottom if extra space exists */
    width: 100%;
    padding-top: 15px; /* Spacing from the card if shrunk */
}

.page-footer p {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.page-footer .accent {
    color: var(--primary);
    font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
    .login-card {
        margin: 16px;
        padding: 32px 24px 24px;
    }

    .card-header h1 {
        font-size: 1.35rem;
    }

    .field-wrapper input[type="text"],
    .field-wrapper input[type="password"] {
        padding: 12px 14px;
        font-size: 0.88rem;
    }

    .btn-login {
        padding: 13px 20px;
        font-size: 0.9rem;
    }

    .bg-blob:nth-child(n+6) {
        display: none;
    }
}

@media (max-width: 380px) {
    .login-card {
        padding: 28px 18px 20px;
    }

    .options-row {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* ---------- Height and Laptop Responsiveness ---------- */
@media (max-height: 780px) {
    .login-page {
        padding: 15px 20px;
    }
    .login-card {
        padding: 24px 24px 18px;
        margin-top: auto;
        margin-bottom: auto;
    }
    .portal-badge {
        margin-bottom: 8px;
        padding: 3px 8px;
    }
    .logo-circle {
        width: 64px;
        height: 64px;
        margin-bottom: 12px;
    }
    .logo-circle img {
        width: 48px;
        height: 48px;
    }
    .card-header h1 {
        font-size: 1.25rem;
    }
    .back-link {
        margin-bottom: 14px;
    }
    .field-group {
        margin-bottom: 12px;
    }
    .field-wrapper input[type="text"],
    .field-wrapper input[type="password"] {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
    .options-row {
        margin-bottom: 14px;
    }
    .btn-login {
        padding: 11px 20px;
        font-size: 0.9rem;
    }
    .ssl-badge {
        margin-top: 14px;
        padding: 6px 14px;
    }
    .page-footer {
        padding-top: 10px;
    }
}
