:root {
    --bg-color: #070a13;
    --card-bg: rgba(13, 20, 38, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --accent-cyan: #06b6d4;
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    --glow-cyan: rgba(6, 182, 212, 0.15);
    --glow-purple: rgba(168, 85, 247, 0.15);
    --glow-opacity: 0.12;
    --toggle-bg: rgba(255, 255, 255, 0.03);
    --toggle-hover-bg: rgba(255, 255, 255, 0.08);
    --title-gradient: linear-gradient(135deg, #ffffff 40%, #c084fc 100%);
    --bubble-ai-bg: rgba(255, 255, 255, 0.04);
    --bubble-ai-border: rgba(255, 255, 255, 0.06);
    --input-bg: rgba(255, 255, 255, 0.04);
}

body.light-theme {
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(15, 23, 42, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --accent-cyan: #0284c7;
    --accent-purple: #7c3aed;
    --accent-green: #059669;
    --glow-cyan: rgba(2, 132, 199, 0.1);
    --glow-purple: rgba(124, 58, 237, 0.1);
    --glow-opacity: 0.06;
    --toggle-bg: rgba(15, 23, 42, 0.03);
    --toggle-hover-bg: rgba(15, 23, 42, 0.06);
    --title-gradient: linear-gradient(135deg, #0f172a 40%, #4f46e5 100%);
    --bubble-ai-bg: rgba(15, 23, 42, 0.03);
    --bubble-ai-border: rgba(15, 23, 42, 0.05);
    --input-bg: rgba(15, 23, 42, 0.03);
}

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

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.site-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow-x: hidden;
    position: relative;
}

@media (min-width: 901px) {
    body {
        height: 100vh;
        overflow: hidden;
    }
    .site-wrapper {
        height: 100vh;
        overflow: hidden;
    }
}

/* Blur page elements when in expanded chat mode */
body.expanded-mode header,
body.expanded-mode main .hero-text,
body.expanded-mode footer {
    filter: blur(10px);
    opacity: 0.15;
    pointer-events: none;
}

header, main .hero-text, footer {
    transition: filter 0.4s ease, opacity 0.4s ease;
}

/* Ambient background glows behind the canvas */
.ambient-glow {
    position: fixed;
    pointer-events: none;
    z-index: -3;
    opacity: var(--glow-opacity);
    transition: opacity 0.3s ease;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
    top: -15%;
    left: -10%;
}

.glow-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
    bottom: -15%;
    right: -10%;
}

/* Backdrop Blur Overlay for Expanded Chat */
.chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 19, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 9;
}
.chat-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

header {
    padding: 1.5rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.05em;
}

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.status-badge.online .status-dot {
    background-color: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 1.5s infinite alternate;
}

.status-badge.offline {
    background: rgba(156, 163, 175, 0.1);
    border: 1px solid rgba(156, 163, 175, 0.2);
    color: var(--text-secondary);
}

.status-badge.offline .status-dot {
    background-color: var(--text-secondary);
    box-shadow: none;
    animation: none;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 1; }
}

.theme-toggle {
    background: var(--toggle-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--toggle-hover-bg);
    border-color: var(--accent-cyan);
    transform: scale(1.05);
}

main {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 10;
}

.hero-container {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 3.5rem;
    align-items: center;
    width: 100%;
}

@media (max-width: 900px) {
    .hero-container {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        padding-bottom: 2rem;
    }
    header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
}

.hero-text h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(2.25rem, 8vw, 4.25rem);
    font-weight: 800;
    line-height: 1.05;
    margin-bottom: 0.25rem;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    transition: background 0.3s ease;
}

.tagline {
    font-size: clamp(1.2rem, 4.5vw, 1.75rem);
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.25rem;
    font-family: 'Space Grotesk', sans-serif;
}

.hero-text p {
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.6;
    transition: color 0.3s ease;
}

/* Compact expertise badges */
.expertise-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 1.5rem 0;
}

@media (max-width: 600px) {
    .expertise-grid {
        grid-template-columns: 1fr;
    }
}

.exp-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: border-color 0.2s ease, background-color 0.3s ease;
}

body.light-theme .exp-item {
    background: rgba(15, 23, 42, 0.01);
}

.exp-item:hover {
    border-color: rgba(6, 182, 212, 0.2);
}

.exp-icon {
    font-size: 1.25rem;
}

.exp-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.exp-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Glassmorphism Card (AI Chat Interface) */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 1.75rem;
    box-shadow: 0 10px 40px 0 rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 420px;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

body.light-theme .glass-card {
    box-shadow: 0 10px 40px 0 rgba(15, 23, 42, 0.08);
}

.glass-card:hover {
    border-color: rgba(6, 182, 212, 0.25);
    box-shadow: 0 15px 45px 0 rgba(6, 182, 212, 0.1);
}

/* Expanded Mode for Chat Modal */
.glass-card.expanded {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    width: 90vw;
    max-width: 750px;
    height: 80vh;
    max-height: 550px;
    z-index: 1000;
    cursor: default;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7), 0 0 50px var(--glow-cyan);
    border-color: rgba(6, 182, 212, 0.3);
}

body.light-theme .glass-card.expanded {
    box-shadow: 0 20px 80px rgba(15, 23, 42, 0.15), 0 0 50px rgba(2, 132, 199, 0.15);
    border-color: rgba(2, 132, 199, 0.25);
}

.terminal-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.75rem;
    flex-shrink: 0;
}

.terminal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 700;
    color: transparent;
    transition: color 0.15s ease;
    user-select: none;
    line-height: 1;
}

.glass-card.expanded .td-red {
    cursor: pointer;
    color: rgba(0, 0, 0, 0.6) !important;
}

.glass-card.expanded .td-red::before {
    content: '×';
}

.glass-card.expanded .terminal-header:hover .td-yellow::before {
    content: '−';
    color: rgba(0, 0, 0, 0.55);
}
.glass-card.expanded .terminal-header:hover .td-green::before {
    content: '+';
    color: rgba(0, 0, 0, 0.55);
}

.td-red { background-color: #ef4444; }
.td-yellow { background-color: #f59e0b; }
.td-green { background-color: #10b981; }

.terminal-title {
    margin-left: 0.5rem;
    font-size: 0.85rem;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Chat history area */
.chat-history {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding-right: 0.5rem;
    padding-bottom: 0.85rem;
}

.chat-history::-webkit-scrollbar {
    width: 4px;
}
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

body.light-theme .chat-history::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.1);
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    font-size: 0.925rem;
    line-height: 1.5;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Markdown elements formatting inside chat bubbles */
.chat-bubble p {
    margin-bottom: 0.5rem;
}
.chat-bubble p:last-child {
    margin-bottom: 0;
}
.chat-bubble ul, .chat-bubble ol {
    margin-bottom: 0.5rem;
    padding-left: 1.2rem;
}
.chat-bubble li {
    margin-bottom: 0.25rem;
}
.chat-bubble code {
    font-family: 'Space Grotesk', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}
.chat-bubble pre {
    background: rgba(0, 0, 0, 0.25);
    padding: 0.6rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 0.5rem;
    border: 1px solid var(--card-border);
}
.chat-bubble pre code {
    background: transparent;
    padding: 0;
    font-size: 0.8em;
}

.bubble-ai {
    background: var(--bubble-ai-bg);
    border: 1px solid var(--bubble-ai-border);
    color: var(--text-primary);
    align-self: flex-start;
    border-top-left-radius: 2px;
}

.bubble-user {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--text-primary);
    align-self: flex-end;
    border-top-right-radius: 2px;
}

body.light-theme .bubble-user {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.15), rgba(124, 58, 237, 0.15));
    border-color: rgba(2, 132, 199, 0.25);
    color: var(--text-primary);
}

.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.5rem 1rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

.chip-container {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.5rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease, background-color 0.3s ease;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
}

body.light-theme .chip-btn {
    background: rgba(15, 23, 42, 0.02);
}

.chip-btn:hover {
    background: rgba(6, 182, 212, 0.1);
    border-color: var(--accent-cyan);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.6rem;
    border-radius: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.light-theme .btn-secondary {
    background: rgba(15, 23, 42, 0.03);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

body.light-theme .btn-secondary:hover {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.15);
}

footer {
    padding: 1.5rem 2rem;
    text-align: center;
    border-top: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: border-color 0.3s ease, color 0.3s ease;
}

footer a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--accent-purple);
    text-decoration: underline;
}

/* Mobile specific overrides and improvements */
@media (max-width: 900px) {
    main {
        padding: 1rem 1.25rem;
    }
    footer {
        padding: 1.5rem 1.25rem;
    }
    .glass-card {
        padding: 1.25rem;
        height: auto;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .expertise-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .glass-card.expanded {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        padding: 1.25rem 1rem 1.5rem 1rem !important;
        border: none !important;
    }
    /* Allow wrapping on mobile to ensure all chips are visible without clipping */
    .chip-container {
        flex-wrap: wrap;
        overflow-x: visible;
        padding-bottom: 0;
    }
    .chip-container::-webkit-scrollbar {
        display: none;
    }
    .chip-btn {
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    .btn {
        width: 100%;
    }
}

/* Prevent scroll on body when chat modal is active */
body.expanded-mode {
    overflow: hidden !important;
}

/* Expand touch area for the close dot on mobile */
@media (max-width: 600px) {
    .glass-card.expanded #mac-close-btn {
        position: relative;
    }
    .glass-card.expanded #mac-close-btn::after {
        content: '';
        position: absolute;
        top: -16px;
        left: -16px;
        right: -16px;
        bottom: -16px;
    }
}

/* Custom Select Styling */
.custom-select {
    position: relative;
    user-select: none;
    font-family: inherit;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 0.75rem;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.custom-select-trigger:hover {
    border-color: rgba(6, 182, 212, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

body.light-theme .custom-select-trigger:hover {
    border-color: rgba(2, 132, 199, 0.4);
    background: rgba(15, 23, 42, 0.05);
}

.custom-select-arrow {
    transition: transform 0.2s ease;
    opacity: 0.8;
}

.custom-select.open .custom-select-arrow {
    transform: rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 170px;
    background: rgba(10, 15, 30, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    z-index: 1100;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    transform: translateY(-8px) scale(0.95);
    pointer-events: none;
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
    transform-origin: top right;
}

body.light-theme .custom-select-options {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.custom-select.open .custom-select-options {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.custom-option {
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.custom-option:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

body.light-theme .custom-option:hover {
    background: rgba(15, 23, 42, 0.04);
}

.custom-option.selected {
    color: var(--text-primary);
    font-weight: 600;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(168, 85, 247, 0.15));
    border-left: 2px solid var(--accent-cyan);
    padding-left: 8px;
}

body.light-theme .custom-option.selected {
    background: linear-gradient(135deg, rgba(2, 132, 199, 0.1), rgba(124, 58, 237, 0.1));
    border-left-color: var(--accent-cyan);
}

@media (max-width: 520px) {
    .terminal-header {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.75rem !important;
    }
    
    .custom-select-options {
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(-8px) scale(0.95) !important;
        transform-origin: top center !important;
    }
    
    .custom-select.open .custom-select-options {
        transform: translateX(-50%) translateY(0) scale(1) !important;
    }
}

/* Disable WebKit search input decorations */
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    display: none;
    -webkit-appearance: none;
}
