/* =============================================
   MULTI-CRM LOGIN — PREMIUM DESIGN SYSTEM
   Shared login page for KVC & IDEEM CRMs
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ────────────────────────────────── */
:root {
    --login-bg: #0A1628;
    --login-bg-gradient: linear-gradient(135deg, #0A1628 0%, #0F2A3A 40%, #132D44 70%, #0A1628 100%);
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-bg-hover: rgba(255, 255, 255, 0.07);

    --accent-cyan: #00ADDA;
    --accent-cyan-glow: rgba(0, 173, 218, 0.30);
    --accent-teal: #327498;
    --accent-purple: #7C3AED;
    --accent-purple-glow: rgba(124, 58, 237, 0.25);

    --text-white: #F1F5F9;
    --text-light: #94A3B8;
    --text-muted: #64748B;
    --text-dim: #475569;

    --success: #10B981;
    --danger: #EF4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    --shadow-glow: 0 0 30px rgba(0, 173, 218, 0.15), 0 0 60px rgba(0, 173, 218, 0.05);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--login-bg);
    background-image: var(--login-bg-gradient);
    color: var(--text-white);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* ── Animated Background Mesh ─────────────── */
.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-mesh::before,
.bg-mesh::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.bg-mesh::before {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-cyan-glow), transparent 70%);
    top: -200px;
    right: -100px;
    animation-delay: -5s;
}

.bg-mesh::after {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-purple-glow), transparent 70%);
    bottom: -150px;
    left: -100px;
    animation-delay: -10s;
}

.bg-mesh .orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.25;
    animation: float 25s ease-in-out infinite;
}

.bg-mesh .orb:nth-child(1) {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(50, 116, 152, 0.4), transparent 70%);
    top: 40%;
    left: 30%;
    animation-delay: -8s;
}

.bg-mesh .orb:nth-child(2) {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0, 173, 218, 0.2), transparent 70%);
    top: 20%;
    right: 20%;
    animation-delay: -15s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(15px, 35px) scale(1.02); }
}

/* ── Grid Lines (subtle) ──────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

/* ── Main Container ───────────────────────── */
.login-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

/* ── Login Card ───────────────────────────── */
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    backdrop-filter: blur(24px) saturate(1.5);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    animation: cardEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-cyan), var(--accent-purple), transparent);
    opacity: 0.6;
}

@keyframes cardEntrance {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Logo Area ────────────────────────────── */
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 36px;
}

.login-logo img {
    height: 56px;
    width: auto;
    object-fit: contain;
    filter: brightness(1.1);
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-white), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo .subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 2.5px;
    margin-top: -8px;
}

.login-description {
    text-align: center;
    color: var(--text-light);
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 32px;
}

/* ── Google Login Button ──────────────────── */
.btn-google-login {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 24px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-white);
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
}

.btn-google-login::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-google-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 173, 218, 0.35);
}

.btn-google-login:hover::before {
    opacity: 1;
}

.btn-google-login:active {
    transform: translateY(0);
}

.btn-google-login i {
    font-size: 20px;
}

.btn-google-login.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ── Spinner ──────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.btn-google-login.loading .spinner {
    display: block;
}

.btn-google-login.loading .btn-text {
    display: none;
}

.btn-google-login.loading i {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Footer Info ──────────────────────────── */
.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-dim);
}

/* ── Status Messages ──────────────────────── */
.login-status {
    text-align: center;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    margin-top: 20px;
    display: none;
    animation: fadeIn 0.3s ease;
}

.login-status.visible {
    display: block;
}

.login-status.error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #FCA5A5;
}

.login-status.success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: #6EE7B7;
}

.login-status.info {
    background: rgba(0, 173, 218, 0.12);
    border: 1px solid rgba(0, 173, 218, 0.25);
    color: #7DD3FC;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── CRM Selector ─────────────────────────── */
.crm-selector {
    display: none;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

.crm-selector.visible {
    display: flex;
    animation: fadeIn 0.4s ease;
}

.crm-selector h3 {
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-white);
    margin-bottom: 4px;
}

.crm-selector p {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.crm-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.crm-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    color: var(--text-white);
    position: relative;
    overflow: hidden;
}

.crm-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-accent, var(--accent-cyan));
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.crm-card:hover {
    background: var(--card-bg-hover);
    border-color: var(--card-accent, var(--accent-cyan));
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
}

.crm-card:hover::after {
    transform: scaleX(1);
}

.crm-card .crm-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(0, 173, 218, 0.12);
    color: var(--accent-cyan);
}

.crm-card[data-crm="IDEEM"] .crm-icon {
    background: rgba(124, 58, 237, 0.12);
    color: var(--accent-purple);
}

.crm-card[data-crm="IDEEM"] {
    --card-accent: var(--accent-purple);
}

.crm-card .crm-name {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.crm-card .crm-desc {
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
}

.crm-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ── User Welcome (shown after auth) ─────── */
.user-welcome {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.user-welcome.visible {
    display: flex;
    animation: fadeIn 0.4s ease;
}

.user-welcome .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--success);
    font-size: 16px;
    flex-shrink: 0;
}

.user-welcome .user-info {
    display: flex;
    flex-direction: column;
}

.user-welcome .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-white);
}

.user-welcome .user-email {
    font-size: 11px;
    color: var(--text-light);
}

/* ── Large Spinner (initial loader) ───────── */
.full-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--login-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    transition: opacity 0.4s ease;
}

.full-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.full-loader .spinner-lg {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 173, 218, 0.2);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.full-loader p {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
}

/* ── Responsive ───────────────────────────── */
@media (max-width: 480px) {
    .login-container {
        padding: 16px;
    }

    .login-card {
        padding: 36px 24px;
    }

    .crm-cards {
        grid-template-columns: 1fr;
    }
}
