/* =========================================================================
   THEME.CSS
   Dark / Light mode system + senior-developer visual polish + AI Assistant
   widget styling for the DevClyde portfolio.

   Scope of this file only:
   1. Design tokens (CSS custom properties) for light + dark themes
   2. Overrides for Bootstrap utility classes so existing markup respects
      the active theme (no HTML structure/content was changed)
   3. Subtle "senior engineer" polish: monospace eyebrow labels, numbered
      section markers, tech-badge chips, refined hover/shadow states
   4. Theme toggle switch UI
   5. AI Assistant floating widget UI
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------------------- */
:root {
    --dc-bg: #ffffff;
    --dc-surface: #F2F5F9;
    --dc-surface-2: #ffffff;
    --dc-panel-dark: #16243D;
    --dc-panel-dark-2: #0f1a2e;
    --dc-text: #787878;
    --dc-text-strong: #16243D;
    --dc-heading: #16243D;
    --dc-border: rgba(0, 0, 0, .08);
    --dc-accent: #015FC9;
    --dc-accent-2: #0dcaf0;
    --dc-shadow: 0 0 30px rgba(0, 0, 0, .06);
    --dc-shadow-hover: 0 12px 34px rgba(1, 95, 201, .14);
    --dc-code: #5b6b8c;
    --dc-scrollbar: #c9d2e0;

    color-scheme: light;
}

[data-theme="dark"] {
    --dc-bg: #0b1220;
    --dc-surface: #121b2e;
    --dc-surface-2: #0e1626;
    --dc-panel-dark: #0a1120;
    --dc-panel-dark-2: #070c18;
    --dc-text: #a7b2c8;
    --dc-text-strong: #eef2f9;
    --dc-heading: #f3f6fc;
    --dc-border: rgba(255, 255, 255, .08);
    --dc-accent: #4da3ff;
    --dc-accent-2: #22d3ee;
    --dc-shadow: 0 0 30px rgba(0, 0, 0, .35);
    --dc-shadow-hover: 0 12px 34px rgba(77, 163, 255, .18);
    --dc-code: #7dd3fc;
    --dc-scrollbar: #24314d;

    color-scheme: dark;
}

/* Smooth theme transition */
html {
    transition: background-color .35s ease;
}

body,
.container-fluid,
.bg-light,
.bg-dark,
.bg-white,
.service-item,
.skills-item,
.education-item,
.experience-item,
.about-img,
.header-img,
.header-content,
.testimonial-carousel,
.form-control,
.status-pill,
.nav-section .navbar .navbar-nav .nav-item,
.ai-widget-panel,
.ai-fab,
.theme-toggle {
    transition: background-color .35s ease, color .35s ease, border-color .35s ease, box-shadow .35s ease;
}

body {
    background-color: var(--dc-bg);
    color: var(--dc-text);
}

/* -------------------------------------------------------------------------
   2. BOOTSTRAP UTILITY OVERRIDES (theme-aware)
   ------------------------------------------------------------------------- */
[data-theme="dark"] body { background-color: var(--dc-bg) !important; }

[data-theme="dark"] .bg-light { background-color: var(--dc-surface) !important; }
[data-theme="dark"] .bg-dark { background-color: var(--dc-panel-dark) !important; }
[data-theme="dark"] .bg-white { background-color: var(--dc-surface-2) !important; }
[data-theme="dark"] .bg-body { background-color: var(--dc-bg) !important; }

[data-theme="dark"] .text-dark { color: var(--dc-heading) !important; }
[data-theme="dark"] .text-body { color: var(--dc-text) !important; }
[data-theme="dark"] p,
[data-theme="dark"] li { color: var(--dc-text); }

[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6,
[data-theme="dark"] .h1, [data-theme="dark"] .h2, [data-theme="dark"] .h3,
[data-theme="dark"] .h4, [data-theme="dark"] .h5, [data-theme="dark"] .h6,
[data-theme="dark"] .display-6 {
    color: var(--dc-heading) !important;
}

[data-theme="dark"] .container-fluid {
    border-bottom: 1px solid var(--dc-border);
}

@media (min-width: 992px) {
    [data-theme="dark"] .container-fluid::before {
        background: var(--dc-panel-dark);
    }
}

[data-theme="dark"] .fs-5,
[data-theme="dark"] a:not(.btn):not(.nav-link) { color: var(--dc-accent); }

[data-theme="dark"] .btn-primary {
    color: #06121f !important;
    background-color: var(--dc-accent) !important;
    border-color: var(--dc-accent) !important;
}
[data-theme="dark"] .btn-primary:hover {
    background: var(--dc-panel-dark-2) !important;
    color: var(--dc-accent) !important;
    border-color: var(--dc-accent) !important;
}

[data-theme="dark"] .btn-light {
    background-color: var(--dc-surface) !important;
    color: var(--dc-accent) !important;
}
[data-theme="dark"] .btn-light:hover {
    background-color: var(--dc-accent) !important;
    color: #06121f !important;
}

[data-theme="dark"] .btn-success { color: #06251b !important; }

[data-theme="dark"] .text-primary { color: var(--dc-accent) !important; }
[data-theme="dark"] .border-primary { border-color: var(--dc-accent) !important; }

[data-theme="dark"] .form-control {
    background-color: var(--dc-surface-2) !important;
    color: var(--dc-text-strong) !important;
}
[data-theme="dark"] .form-control::placeholder { color: #6b7791; }
[data-theme="dark"] .form-floating > label { color: #6b7791; }

[data-theme="dark"] .education-content .education-item,
[data-theme="dark"] .experience-content .experience-item,
[data-theme="dark"] .service-content .service-item {
    background-color: var(--dc-surface-2);
    box-shadow: var(--dc-shadow);
    border: 1px solid var(--dc-border);
}

[data-theme="dark"] .nav-section .navbar .navbar-nav .nav-item {
    background: var(--dc-surface-2);
    color: var(--dc-text);
    border-color: var(--dc-border);
}
[data-theme="dark"] .navbar-nav .nav-link span {
    border-right: 1px solid var(--dc-border);
    color: var(--dc-text);
}

[data-theme="dark"] .testimonial-carousel.bg-light { background-color: var(--dc-surface) !important; }
[data-theme="dark"] .testimonial-carousel .owl-dots .owl-dot img { filter: brightness(.85); }

[data-theme="dark"] .contact-content iframe {
    filter: invert(90%) hue-rotate(180deg) contrast(90%) brightness(95%);
}

[data-theme="dark"] .footer.bg-dark { background-color: var(--dc-panel-dark-2) !important; }

[data-theme="dark"] ::selection {
    background: var(--dc-accent);
    color: #06121f;
}

/* Scrollbar theming (both themes, subtle) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--dc-scrollbar);
    border-radius: 10px;
}

/* -------------------------------------------------------------------------
   3. SENIOR-DEVELOPER POLISH (theme-agnostic, works both modes)
   ------------------------------------------------------------------------- */

/* Eyebrow / sub-title labels read like a code comment, e.g. "// About Me" */
.sub-title {
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Courier New", monospace !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--dc-accent-2) !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px !important;
}
.sub-title::before {
    content: "//";
    color: var(--dc-accent);
    opacity: .8;
}

/* Card hover-lift for the repeating item components */
.education-content .education-item,
.experience-content .experience-item,
.service-content .service-item,
.skills-content .skills-item,
.portfolio-content .portfolio-item {
    transition: transform .35s ease, box-shadow .35s ease;
}
.education-content .education-item:hover,
.experience-content .experience-item:hover,
.service-content .service-item:hover {
    transform: translateY(-4px);
}

/* Skills grid: tech badge treatment */
.skills-content .skills-item {
    border: 1px solid var(--dc-border);
    background: var(--dc-surface-2);
    box-shadow: var(--dc-shadow);
}
.skills-content .skills-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--dc-shadow-hover);
    border-color: var(--dc-accent);
}

/* Status / availability pill (re-presents existing "Gigs: Available" data) */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 12px;
    letter-spacing: .04em;
    color: #6be3a8;
    background: rgba(107, 227, 168, .1);
    border: 1px solid rgba(107, 227, 168, .35);
    padding: 6px 12px;
    border-radius: 999px;
    margin-bottom: 18px;
}
.status-pill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
    animation: dc-pulse 2s infinite;
}
@keyframes dc-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
    70%  { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* Hero tech-stack strip built from existing skill set */
.tech-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 20px;
}
.tech-chip {
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Courier New", monospace;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--dc-border);
    color: var(--dc-code);
    background: rgba(1, 95, 201, .06);
}
[data-theme="dark"] .tech-chip { background: rgba(77, 163, 255, .08); }

/* Focus visibility for keyboard users (senior-dev accessibility touch) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--dc-accent);
    outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   4. THEME TOGGLE
   ------------------------------------------------------------------------- */
.theme-toggle {
    background: var(--dc-surface-2);
    border: 1px solid var(--dc-border);
    color: var(--dc-heading);
    cursor: pointer;
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    display: none;
}
[data-theme="light"] .theme-toggle .icon-sun { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }

/* Standalone floating toggle for small screens where the side-nav collapses */
.theme-toggle-floating {
    position: fixed;
    left: 30px;
    bottom: 30px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 98;
    box-shadow: var(--dc-shadow);
}

/* -------------------------------------------------------------------------
   5. AI ASSISTANT WIDGET
   ------------------------------------------------------------------------- */
.ai-fab {
    position: fixed;
    right: 30px;
    bottom: 92px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dc-accent), var(--dc-accent-2));
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 8px 24px rgba(1, 95, 201, .35);
    z-index: 100;
    cursor: pointer;
}
.ai-fab:hover { transform: translateY(-3px); }
.ai-fab .ai-fab-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #34d399;
    border: 2px solid var(--dc-bg);
}

.ai-widget-panel {
    position: fixed;
    right: 30px;
    bottom: 158px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    max-height: calc(100vh - 200px);
    background: var(--dc-surface-2);
    border: 1px solid var(--dc-border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    opacity: 0;
    transform: translateY(16px) scale(.98);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.ai-widget-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ai-widget-header {
    background: linear-gradient(135deg, var(--dc-panel-dark), var(--dc-panel-dark-2));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-widget-header .ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dc-accent), var(--dc-accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.ai-widget-header .ai-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}
.ai-widget-header .ai-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,.65);
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}
.ai-widget-header .ai-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}
.ai-widget-header .ai-close:hover { color: #fff; }

.ai-widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--dc-bg);
}

.ai-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-line;
}
.ai-msg.bot {
    align-self: flex-start;
    background: var(--dc-surface);
    color: var(--dc-text-strong);
    border-bottom-left-radius: 3px;
}
.ai-msg.user {
    align-self: flex-end;
    background: var(--dc-accent);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}
[data-theme="dark"] .ai-msg.user { color: #06121f; }

.ai-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 12px;
    background: var(--dc-surface);
    border-radius: 12px;
}
.ai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dc-code);
    animation: dc-typing 1.2s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dc-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 14px 12px;
    background: var(--dc-bg);
}
.ai-suggestion-chip {
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--dc-border);
    background: var(--dc-surface);
    color: var(--dc-text-strong);
    cursor: pointer;
}
.ai-suggestion-chip:hover {
    border-color: var(--dc-accent);
    color: var(--dc-accent);
}

.ai-widget-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--dc-border);
    background: var(--dc-surface-2);
}
.ai-widget-footer input {
    flex: 1;
    border: 1px solid var(--dc-border);
    background: var(--dc-bg);
    color: var(--dc-text-strong);
    border-radius: 999px;
    padding: 9px 14px;
    font-size: 13px;
    outline: none;
}
.ai-widget-footer input:focus { border-color: var(--dc-accent); }
.ai-widget-footer button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--dc-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
[data-theme="dark"] .ai-widget-footer button { color: #06121f; }

@media (max-width: 480px) {
    .ai-widget-panel {
        right: 16px;
        left: 16px;
        width: auto;
        bottom: 150px;
    }
    .ai-fab { right: 20px; }
    .theme-toggle-floating { left: 20px; }
}
