/* --- Global Color Variables: Slate & Teal/Orange --- */
:root {
    /* Dark Mode (Default) */
    --bg-primary: #1e293b;     /* Dark Slate Blue */
    --bg-secondary: #334155;   /* Section Background */
    --text-primary: #f8fafc;   /* Off-White text */
    --text-secondary: #94a3b8; /* Muted Gray text */
    --accent-color: #14b8a6;   /* Teal Accent */
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Light Mode Variables */
body.light-mode {
    --bg-primary: #f1f5f9;     /* Light Gray/Blue */
    --bg-secondary: #ffffff;   /* Pure White */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #f97316;   /* Orange Accent */
    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    text-align: center;
    scroll-behavior: smooth;
    transition: background-color 0.5s, color 0.5s;
}

h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* === Mode Toggle Button (Fixed Position) === */
#mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: var(--bg-secondary);
    border: 2px solid var(--text-primary);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 50%; /* Circular button */
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-subtle);
}

#mode-toggle:hover {
    background: var(--accent-color);
    color: var(--bg-secondary);
    border-color: var(--accent-color);
    transform: rotate(10deg);
}


/* === Section Layout === */
#first, #about, #skills, #projects, #contact {
    padding: 100px 5%;
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

h2 {
    font-size: 3em;
    margin-bottom: 50px;
    color: var(--text-primary);
}

/* --- 1. Hero Section (#first) --- */
#first {
    padding-top: 200px;
    padding-bottom: 200px;
    /* CORRECTED: Use Flexbox for clean vertical alignment */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Typing Animation Layout */
#hero-title {
    /* CORRECTED: Use flex for proper alignment and wrapping */
    display: flex;
    align-items: baseline; 
    justify-content: center;
    margin-bottom: 15px;
    flex-wrap: wrap; /* Allows text to wrap on small screens */
    /* REMOVED BROKEN 'height' PROPERTY */
}

#hero-title h1 {
    font-size: 5em;
    font-weight: 900;
    margin-right: 20px; /* Space between "Alex" and the tagline */
    margin-bottom: 0;
}

#typing-text {
    font-size: 2.5em; /* CORRECTED: Reduced size for better balance */
    font-weight: 500;
    color: var(--accent-color);
    
    /* Blinking Cursor Effect */
    border-right: 3px solid var(--accent-color);
    animation: blink-caret 0.75s step-end infinite;
    white-space: nowrap; /* Prevent line wrap */
}

@keyframes blink-caret {
    from, to { border-color: transparent }
    50% { border-color: var(--accent-color); }
}

#first p {
    font-size: 1.5em;
    margin-bottom: 40px;
    color: var(--accent-color); /* Highlight the bio line */
    font-weight: 500;
    margin-top: 10px; /* CORRECTED: Adjusted margin */
}

/* Hero Buttons */
#first button {
    font-size: 1.1em;
    padding: 15px 30px;
    margin: 10px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    font-weight: 600;
}

#proj {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    border: none;
}

#cont {
    background-color: transparent;
    color: var(--accent-color);
    border: 2px solid var(--accent-color);
}

#proj:hover {
    background-color: color-mix(in srgb, var(--accent-color) 80%, black 20%);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px color-mix(in srgb, var(--accent-color) 60%, transparent 40%);
}

#cont:hover {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    transform: translateY(-2px);
}

#first button i {
    margin-right: 8px;
}

/* --- 2. About Section --- */
#about {
    background-color: var(--bg-secondary);
}

#about p {
    font-size: 1.25em;
    color: var(--text-secondary);
    max-width: 800px;
    margin: 0 auto;
}
#about b {
    color: var(--accent-color); /* Highlight key terms */
}

/* --- 3. Skills Section --- */
#skills {
    background-color: var(--bg-primary);
}

.skill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

#skills .skill {
    padding: 10px 20px;
    border-radius: 50px; /* Pill shape */
    background-color: var(--bg-secondary);
    font-size: 1em;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s ease;
    border: 1px solid var(--text-secondary);
}

#skills .skill:hover {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    border-color: var(--accent-color);
    transform: scale(1.05);
}

/* --- 4. Projects Section --- */
#projects {
    background-color: var(--bg-secondary);
}

.project-link {
    display: block;
    text-decoration: none;
    color: inherit;
    padding: 30px;
    margin: 30px auto;
    border-radius: 12px;
    background-color: var(--bg-primary); /* Darker project box on lighter section */
    border: 1px solid var(--bg-secondary);
    max-width: 700px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-align: left;
    box-shadow: var(--shadow-subtle);
}

.project-link:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: var(--accent-color);
}

.project-content h3 {
    font-size: 1.7em;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.project-content p {
    font-size: 1.05em;
    color: var(--text-secondary);
}

/* --- 5. Contact Section (Sized Down) --- */
#contact {
    background-color: var(--bg-primary);
    padding-top: 100px; /* Reduced vertical space */
    padding-bottom: 120px;
}

.contact-links {
    margin-top: 50px;
    display: flex;
    gap: 30px;
    justify-content: center;
}

.contact-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-size: 1.1em;
    padding: 15px 40px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.contact-btn {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    border: 2px solid var(--accent-color);
}

.contact-btn:hover {
    background-color: color-mix(in srgb, var(--accent-color) 80%, black 20%);
    transform: scale(1.05);
}

.contact-btn.linkedin {
    background-color: transparent;
    color: var(--text-primary);
    border: 2px solid var(--text-primary);
}

.contact-btn.linkedin:hover {
    background-color: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

/* --- Footer --- */
#footer {
    padding: 40px;
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.9em;
    text-align: center;
}
/* ===== AI CHATBOT STYLES ===== */

/* Chat Placeholder Button */
#AI-Chat-placeholder {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

#AI-Chat-placeholder p {
    display: none; /* Hide text on desktop, show on hover if you want */
}

#AI-Chat-toggle {
    background: var(--accent-color);
    color: var(--bg-primary);
    border: none;
    padding: 16px 28px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 20px rgba(20, 184, 166, 0.4);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

body.light-mode #AI-Chat-toggle {
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.3);
}

#AI-Chat-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 25px rgba(20, 184, 166, 0.6);
}

body.light-mode #AI-Chat-toggle:hover {
    box-shadow: 0 6px 25px rgba(249, 115, 22, 0.5);
}

#AI-Chat-toggle:active {
    transform: translateY(-1px) scale(1.02);
}

/* Chat Window */
#AI-Chat-window {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 40px);
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: var(--shadow-subtle), 0 0 0 1px rgba(255, 255, 255, 0.1);
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: var(--accent-color);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

.chat-header h3 {
    margin: 0;
    color: var(--bg-primary);
    font-size: 18px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

#close-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--bg-primary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 300;
    line-height: 1;
}

#close-chat:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Messages Area */
#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-primary);
}

/* Custom Scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
    opacity: 0.8;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
    font-family: 'Inter', sans-serif;
}

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

.user-message {
    background: var(--accent-color);
    color: var(--bg-primary);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.bot-message {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-mode .bot-message {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.bot-message b {
    color: var(--accent-color);
    font-weight: 600;
}

.bot-message a {
    color: var(--accent-color);
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.bot-message a:hover {
    opacity: 0.8;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

body.light-mode .typing-indicator {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Chat Input Area */
.chat-input {
    display: flex;
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    gap: 10px;
    border-radius: 0 0 16px 16px;
}

body.light-mode .chat-input {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

#user-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

body.light-mode #user-input {
    border: 1px solid rgba(0, 0, 0, 0.15);
}

#user-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

body.light-mode #user-input:focus {
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

#user-input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    background: var(--accent-color);
    border: none;
    color: var(--bg-primary);
    padding: 12px 18px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

#send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

body.light-mode #send-btn:hover {
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

#send-btn:active {
    transform: scale(0.98);
}

/* ===== RESPONSIVE DESIGN ===== */

/* Tablets (Portrait and Landscape) */
@media (max-width: 768px) {
    #AI-Chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 10px;
        right: 10px;
    }

    #AI-Chat-toggle {
        padding: 14px 24px;
        font-size: 14px;
    }

    .message {
        max-width: 85%;
        font-size: 13px;
    }

    .chat-header h3 {
        font-size: 16px;
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    #AI-Chat-placeholder {
        bottom: 15px;
        right: 15px;
    }

    #AI-Chat-toggle {
        padding: 12px 20px;
        font-size: 13px;
        border-radius: 40px;
    }

    #AI-Chat-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-width: 100vw;
        max-height: 100vh;
    }

    .chat-header {
        padding: 16px;
        border-radius: 0;
    }

    .chat-header h3 {
        font-size: 16px;
    }

    #close-chat {
        width: 28px;
        height: 28px;
        font-size: 20px;
    }

    #chat-messages {
        padding: 16px;
        gap: 10px;
    }

    .message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-input {
        padding: 12px;
        gap: 8px;
    }

    #user-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    #send-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    #AI-Chat-toggle {
        padding: 10px 18px;
        font-size: 12px;
    }

    .chat-header h3 {
        font-size: 14px;
    }

    .message {
        font-size: 13px;
        padding: 9px 12px;
    }

    #user-input {
        font-size: 13px;
        padding: 9px 12px;
    }
}

/* Landscape Mode on Mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #AI-Chat-window {
        height: 100vh;
    }

    #chat-messages {
        padding: 12px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-input {
        padding: 10px;
    }
}

/* Large Desktops */
@media (min-width: 1440px) {
    #AI-Chat-window {
        width: 420px;
        height: 650px;
    }

    .message {
        font-size: 15px;
    }

    #user-input {
        font-size: 15px;
    }
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    #AI-Chat-window,
    .message,
    #AI-Chat-toggle,
    #send-btn,
    #close-chat {
        animation: none;
        transition: none;
    }

    .typing-indicator span {
        animation: none;
    }
}

/* Touch Device Improvements */
@media (hover: none) and (pointer: coarse) {
    #send-btn,
    #close-chat,
    #AI-Chat-toggle {
        min-height: 44px; /* iOS recommended touch target */
        min-width: 44px;
    }

    #user-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}
