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

:root {
    --primary: #203143;
    --primary-light: #2a4157;
    --accent: #27a736;
    --accent-hover: #21902f;
    --accent-glow: rgba(39, 167, 54, 0.2);
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-hover: #f8f9fa;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.1);
    --gradient-primary: linear-gradient(135deg, #203143 0%, #2a4157 100%);
    --gradient-accent: linear-gradient(135deg, #27a736 0%, #2ecc40 100%);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* =========================================
   LOGIN PAGE
   ========================================= */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 20px;
    background: var(--gradient-primary);
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(39, 167, 54, 0.08) 0%, transparent 50%);
    animation: rotateGlow 20s linear infinite;
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    width: 100%;
    max-width: 460px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(39, 167, 54, 0.1);
    padding: 48px 40px;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.brand-logo {
    margin-bottom: 32px;
}

.brand-logo h2 {
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-logo h2 span {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-logo p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--primary);
}

.login-card > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
    text-align: left;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--border-light);
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: var(--text);
    font-weight: 500;
}

.login-feature svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

/* =========================================
   CHAT PLATFORM
   ========================================= */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.sidebar-brand h2 span {
    color: var(--accent);
}

.sidebar-menu {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
    gap: 12px;
    font-size: 0.92rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.sidebar-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-left-color: var(--accent);
}

.sidebar-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 24px;
}

/* USER PROFILE */
.user-profile {
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-email {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* MAIN CHAT */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    position: relative;
    min-width: 0;
}

.chat-header {
    height: 68px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-shrink: 0;
}

.chat-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-title {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

.chat-subtitle {
    font-size: 0.78rem;
    color: var(--text-light);
    font-weight: 400;
}

.menu-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--primary);
    padding: 6px;
    border-radius: 8px;
    transition: var(--transition);
}

.menu-toggle-btn:hover {
    background: var(--border-light);
}

/* CHAT BOX */
.chat-box {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* MESSAGES */
.message {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 0.92rem;
    position: relative;
    animation: msgAppear 0.3s ease-out;
}

@keyframes msgAppear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-ai {
    background: var(--surface);
    color: var(--text);
    align-self: flex-start;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message-user {
    background: var(--gradient-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(32, 49, 67, 0.15);
}

.message-system {
    background: linear-gradient(135deg, rgba(39, 167, 54, 0.08), rgba(39, 167, 54, 0.04));
    color: var(--text);
    align-self: center;
    text-align: center;
    font-size: 0.85rem;
    border: 1px solid rgba(39, 167, 54, 0.15);
    max-width: 85%;
}

.message-typing {
    background: var(--surface);
    align-self: flex-start;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 5px;
    padding: 16px 22px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* INPUT AREA */
.input-area {
    padding: 16px 24px 20px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: 28px;
    padding: 6px 8px 6px 20px;
    border: 1px solid var(--border);
    gap: 8px;
    transition: var(--transition);
}

.input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-container input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 4px;
    font-size: 0.92rem;
    outline: none;
    color: var(--text);
    font-family: inherit;
}

.input-container input::placeholder {
    color: var(--text-light);
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.action-btn:hover {
    background: var(--border-light);
    color: var(--primary);
}

.btn-send {
    background: var(--gradient-accent);
    color: white;
}

.btn-send:hover {
    opacity: 0.9;
    color: white;
    transform: scale(1.05);
}

/* INPUT HINT */
.input-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-light);
    padding-top: 8px;
}

/* =========================================
   WELCOME SCREEN (initial empty chat)
   ========================================= */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 40px;
    gap: 16px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gradient-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 8px 24px var(--accent-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 8px 24px var(--accent-glow); }
    50% { box-shadow: 0 8px 40px rgba(39, 167, 54, 0.35); }
}

.welcome-icon svg {
    width: 36px;
    height: 36px;
    color: white;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.welcome-screen p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.5;
}

/* =========================================
   CV PROGRESS BAR
   ========================================= */
.cv-progress {
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cv-progress-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cv-progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.cv-progress-fill {
    height: 100%;
    background: var(--gradient-accent);
    border-radius: 3px;
    transition: width 0.6s ease;
    width: 0%;
}

.cv-progress-text {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
    text-align: right;
}

/* =========================================
   LOADING OVERLAY
   ========================================= */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--gradient-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 20px;
    transition: opacity 0.5s ease;
}

.global-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.global-loader h2 {
    font-size: 2rem;
    font-weight: 900;
    color: white;
    letter-spacing: -1px;
}

.global-loader h2 span {
    color: var(--accent);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =========================================
   EXPORT PDF BUTTON
   ========================================= */
.btn-export {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gradient-accent);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-export:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-export svg {
    width: 16px;
    height: 16px;
}

.btn-export:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle-btn {
        display: flex !important;
    }

    .message {
        max-width: 88%;
    }

    .login-card {
        padding: 36px 28px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 0 16px;
    }

    .chat-box {
        padding: 16px;
    }

    .input-area {
        padding: 12px 16px 16px;
    }

    .message {
        max-width: 92%;
        font-size: 0.88rem;
    }
}
