/* ================================================
   WeatherWear AI — Styles
   Aesthetic: Dark luxury editorial with warm accents
   ================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: #16161f;
    --bg-input: #1c1c28;
    --border: rgba(255,255,255,0.07);
    --border-hover: rgba(255,255,255,0.15);

    --accent: #f4a94e;
    --accent-light: #f8c47a;
    --accent-glow: rgba(244,169,78,0.2);
    --accent-secondary: #7c6af5;

    --text-primary: #f0ede8;
    --text-secondary: #8a8799;
    --text-muted: #4a4858;

    --user-bubble: linear-gradient(135deg, #f4a94e, #e8843a);
    --bot-bubble: #1c1c28;

    --orb-1: rgba(244,169,78,0.12);
    --orb-2: rgba(124,106,245,0.08);
    --orb-3: rgba(244,169,78,0.06);

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 64px rgba(0,0,0,0.6);
    --glow: 0 0 24px rgba(244,169,78,0.15);

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --sidebar-width: 280px;
    --header-height: 64px;
    --input-height: 80px;

    --font-display: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light mode */
body.light-mode {
    --bg-primary: #f5f3ef;
    --bg-secondary: #ede9e3;
    --bg-card: #ffffff;
    --bg-input: #f0ece6;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.15);

    --text-primary: #1a1820;
    --text-secondary: #6b6478;
    --text-muted: #a09aad;

    --bot-bubble: #ffffff;
    --orb-1: rgba(244,169,78,0.15);
    --orb-2: rgba(124,106,245,0.08);
    --orb-3: rgba(244,169,78,0.08);

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.08);
    --shadow-lg: 0 24px 64px rgba(0,0,0,0.12);
    --glow: 0 0 24px rgba(244,169,78,0.2);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    transition: background var(--transition), color var(--transition);
}

/* ---------- Animated Background ---------- */
.bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: floatOrb 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--orb-1);
    top: -200px;
    right: -100px;
    animation-delay: 0s;
    animation-duration: 25s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--orb-2);
    bottom: -100px;
    left: 100px;
    animation-delay: -8s;
    animation-duration: 30s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--orb-3);
    top: 50%;
    left: 40%;
    animation-delay: -15s;
    animation-duration: 22s;
}

@keyframes floatOrb {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.noise-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.4;
    pointer-events: none;
}

/* ---------- Layout ---------- */
.app-wrapper {
    position: relative;
    z-index: 2;
    display: flex;
    height: 100vh;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    gap: 8px;
    overflow-y: auto;
    transition: transform var(--transition), background var(--transition);
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

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

.logo-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px var(--accent));
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.close-sidebar:hover {
    color: var(--text-primary);
    background: var(--border);
}

.sidebar-section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* City input */
.city-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.city-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    width: 100%;
}

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

.city-input::placeholder {
    color: var(--text-muted);
}

.city-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--accent);
    color: #0a0a0f;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
}

.city-btn:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(244,169,78,0.3);
}

.city-btn:active {
    transform: translateY(0);
}

/* Weather card */
.weather-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-top: 10px;
    animation: fadeInUp 0.4s ease;
}

.weather-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.weather-info {
    flex: 1;
}

.weather-temp {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--accent);
    line-height: 1;
}

.weather-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: capitalize;
}

.weather-details {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.weather-details span {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 20px;
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    cursor: pointer;
    width: 100%;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: border-color var(--transition);
}

.theme-toggle:hover {
    border-color: var(--border-hover);
}

.theme-icon {
    font-size: 1rem;
}

.theme-text {
    flex: 1;
    text-align: left;
}

.toggle-pill {
    width: 36px;
    height: 20px;
    background: var(--text-muted);
    border-radius: 10px;
    position: relative;
    transition: background var(--transition);
}

.toggle-pill.active {
    background: var(--accent);
}

.toggle-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform var(--transition);
}

.toggle-pill.active .toggle-dot {
    transform: translateX(16px);
}

/* Clear button */
.clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all var(--transition);
}

.clear-btn:hover {
    background: rgba(255,80,80,0.08);
    border-color: rgba(255,80,80,0.3);
    color: #ff6b6b;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-footer strong {
    color: var(--accent);
}

/* ---------- Chat Area ---------- */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Header */
.chat-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-shrink: 0;
}

.menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

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

.menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 8px #4ade80;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.85); }
}

.model-badge {
    font-size: 0.7rem;
    font-weight: 600;
    font-family: var(--font-display);
    letter-spacing: 0.05em;
    color: var(--accent);
    background: var(--accent-glow);
    border: 1px solid rgba(244,169,78,0.2);
    padding: 3px 10px;
    border-radius: 20px;
}

/* ---------- Chat Messages ---------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

/* Message base */
.message {
    display: flex;
    gap: 12px;
    max-width: 75%;
    animation: fadeInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Bot message */
.bot-message {
    align-self: flex-start;
}

/* User message */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* Avatars */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    align-self: flex-end;
}

.bot-avatar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--glow);
}

.user-avatar {
    background: var(--accent);
    font-size: 0.9rem;
    font-weight: 700;
    color: #0a0a0f;
    font-family: var(--font-display);
}

/* Bubbles */
.bubble {
    background: var(--bot-bubble);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    padding: 14px 18px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.user-message .bubble {
    background: var(--user-bubble);
    border: none;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    color: #0a0a0f;
    box-shadow: 0 4px 16px rgba(244,169,78,0.25);
}

.bubble p {
    margin-bottom: 8px;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble ul {
    padding-left: 20px;
    margin: 8px 0;
}

.bubble li {
    margin-bottom: 4px;
}

.bubble strong {
    font-weight: 600;
}

.bubble em {
    font-style: italic;
    color: var(--text-secondary);
}

.user-message .bubble em {
    color: rgba(10,10,15,0.6);
}

/* Quick prompts */
.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.quick-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.quick-btn:hover {
    background: var(--accent-glow);
    border-color: rgba(244,169,78,0.3);
    color: var(--accent);
    transform: translateY(-1px);
}

/* Timestamp */
.msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .msg-time {
    text-align: right;
}

/* ---------- Typing Indicator ---------- */
.typing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 0 20px 12px;
    animation: fadeInUp 0.3s ease;
}

.typing-bubble {
    background: var(--bot-bubble);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    padding: 14px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-bubble span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

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

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Input Area ---------- */
.chat-input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 10px 10px 10px 18px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.user-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    max-height: 120px;
    scrollbar-width: none;
}

.user-input::placeholder {
    color: var(--text-muted);
}

.user-input::-webkit-scrollbar {
    display: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--transition);
    color: #0a0a0f;
}

.send-btn:hover {
    background: var(--accent-light);
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(244,169,78,0.4);
}

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    letter-spacing: 0.02em;
}

/* ---------- Weather Message Card ---------- */
.weather-summary-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-input));
    border: 1px solid rgba(244,169,78,0.2);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.weather-summary-card .wsci {
    font-size: 1.8rem;
}

.weather-summary-card .wsinf {
    flex: 1;
}

.weather-summary-card .wsname {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
}

.weather-summary-card .wstemp {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent);
    font-family: var(--font-display);
}

.weather-summary-card .wsdesc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------- Error message ---------- */
.error-msg {
    color: #ff6b6b;
    font-size: 0.85rem;
    padding: 8px 12px;
    background: rgba(255,107,107,0.08);
    border: 1px solid rgba(255,107,107,0.2);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

/* ---------- Overlay for mobile sidebar ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.sidebar-overlay.visible {
    display: block;
}

/* ---------- Scrollbar styling ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .close-sidebar {
        display: block;
    }

    .menu-btn {
        display: flex;
    }

    .message {
        max-width: 90%;
    }

    .quick-prompts {
        gap: 6px;
    }

    .quick-btn {
        font-size: 0.75rem;
        padding: 5px 12px;
    }

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

    .chat-input-area {
        padding: 10px 12px 14px;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 95%;
    }

    .bubble {
        font-size: 0.88rem;
        padding: 12px 14px;
    }

    .model-badge {
        display: none;
    }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
