/* HexaClima — Estilos */

:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2733;
    --bg-card: #1e2d3d;
    --text-primary: #e8edf2;
    --text-secondary: #8899aa;
    --accent: #00bcd4;
    --accent-hover: #00e5ff;
    --border: #2a3a4a;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="light"] {
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a2733;
    --text-secondary: #5a6a7a;
    --accent: #0097a7;
    --accent-hover: #00838f;
    --border: #d0dae4;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

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

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

/* ── Header ── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    padding-top: calc(10px + var(--safe-top));
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    min-height: 56px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

/* ── Hamburger (hidden on desktop) ── */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
    -webkit-tap-highlight-color: transparent;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ── Controles ── */

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.var-select {
    padding: 7px 14px;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.var-select:hover,
.var-select:focus {
    border-color: var(--accent);
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-icon.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: var(--danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.header-clock {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.status-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    transition: border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.status-btn:hover {
    border-color: var(--accent);
}

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

/* ── Modal Estações ── */

.stations-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 25, 35, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    transition: opacity 0.2s;
}

.stations-modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.stations-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.stations-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.stations-modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stations-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 18px;
    -webkit-overflow-scrolling: touch;
}

.stations-group-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 10px 0 6px;
}

.stations-group-title:first-child {
    margin-top: 0;
}

.station-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.8rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.station-status-item:last-child {
    border-bottom: none;
}

.station-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.station-status-dot.online { background: var(--success); }
.station-status-dot.offline { background: var(--danger); }

/* ── Mapa ── */

.map-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* ── Sidebar (detalhe da estação) ── */

.sidebar {
    position: absolute;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 900;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar.open {
    right: 0;
}

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

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

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

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    -webkit-overflow-scrolling: touch;
}

/* ── Cards de variáveis ── */

.readings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.reading-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.reading-card .label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.reading-card .label.no-transform {
    text-transform: none;
}

.reading-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.reading-card .unit {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ── Predição ── */

.prediction-section {
    margin-bottom: 16px;
}

.prediction-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.prediction-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prediction-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.prediction-card.rain {
    border-color: #1e88e5;
    background: rgba(30, 136, 229, 0.1);
}

.prediction-card.no-rain {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.06);
}

.pred-horizon {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 40px;
}

.pred-bar-wrap {
    flex: 1;
    margin: 0 12px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.pred-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.pred-bar.low { background: var(--success); }
.pred-bar.medium { background: var(--warning); }
.pred-bar.high { background: var(--danger); }

.pred-prob {
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

.pred-detail {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.prediction-loading {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 12px;
}

.prediction-error {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 8px;
}

.pred-indicators-section {
    margin-top: 8px;
}

.pred-indicators-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.pred-indicators-title {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pred-info-btn {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 700;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-family: serif;
}

.pred-info-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pred-info-tooltip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 8px;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.pred-info-tooltip.hidden {
    display: none;
}

.pred-info-tooltip p {
    margin-bottom: 6px;
}

.pred-info-tooltip strong {
    color: var(--text-primary);
}

.pred-info-tooltip ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.pred-info-tooltip li {
    margin-bottom: 3px;
}

.pred-indicators {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pred-indicator {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

/* ── Gráfico ── */

.chart-section {
    margin-top: 8px;
}

.chart-section h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    height: 220px;
}

/* ── Loading ── */

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 25, 35, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

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

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

/* ── Hide markers via class ── */

#map.hide-markers .leaflet-marker-pane {
    visibility: hidden !important;
    opacity: 0 !important;
}

/* ── Marker label customizado ── */

.station-marker {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 3px 7px;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    text-align: center;
    line-height: 1.3;
}

.station-marker .name {
    font-size: 0.6rem;
    font-weight: 400;
    color: var(--text-secondary);
    display: block;
}

/* ── Tooltip da estação ── */

.station-tooltip-container {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow) !important;
    padding: 0 !important;
    color: var(--text-primary) !important;
}

.station-tooltip-container .leaflet-tooltip-tip {
    border-top-color: var(--bg-secondary) !important;
}

.station-tooltip {
    padding: 8px 10px;
    min-width: 140px;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
    font-size: 0.72rem;
}

.tooltip-label {
    color: var(--text-secondary);
}

.tooltip-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Legenda do heatmap ── */

.legend {
    position: absolute;
    bottom: 30px;
    left: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 800;
    box-shadow: var(--shadow);
}

.legend-title {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.legend-bar {
    width: 180px;
    height: 12px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ── Forecast Panel ── */

.forecast-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    max-height: 45vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 800;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.forecast-panel.hidden { display: none; }

.forecast-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.forecast-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    flex: 1;
}

.forecast-source {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.forecast-body {
    padding: 12px 16px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.forecast-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.forecast-chart-wrap {
    height: 160px;
}

.forecast-chart-wrap h4 {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.forecast-chart-wrap canvas {
    width: 100% !important;
    height: 130px !important;
}

/* ============================================================
   RESPONSIVO — Mobile (max-width: 768px)
   ============================================================ */

@media (max-width: 640px) {

    /* ── Header mobile ── */
    .header {
        padding: 8px 12px;
        padding-top: calc(8px + var(--safe-top));
        min-height: 48px;
        position: relative;
    }

    .header-left {
        gap: 10px;
    }

    .logo-img {
        height: 26px;
    }

    /* Hamburger visible on mobile */
    .hamburger {
        display: flex;
    }

    /* Controls hidden by default on mobile, shown via JS toggle */
    .controls-right {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        padding: 12px 16px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        z-index: 1100;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
        animation: slideDown 0.2s ease;
    }

    .controls-right.mobile-open {
        display: flex;
    }

    @keyframes slideDown {
        from { opacity: 0; transform: translateY(-8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    /* Variable select: full width on mobile */
    .controls-var {
        flex: 1;
        min-width: 0;
    }

    .var-select {
        width: 100%;
        font-size: 0.82rem;
        padding: 8px 10px;
    }

    /* Larger touch targets on mobile */
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 1.15rem;
    }

    .status-btn {
        padding: 8px 12px;
    }

    /* ── Sidebar mobile: full screen overlay ── */
    .sidebar {
        width: 100%;
        right: -100%;
        border-left: none;
        z-index: 1200;
    }

    .sidebar.open {
        right: 0;
    }

    .sidebar-header {
        padding: 14px 16px;
    }

    .sidebar-close {
        width: 44px;
        height: 44px;
        font-size: 1.6rem;
    }

    .sidebar-body {
        padding: 14px 16px;
        padding-bottom: calc(14px + var(--safe-bottom));
    }

    /* Reading cards: 2 columns but smaller */
    .readings-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .reading-card {
        padding: 10px 8px;
    }

    .reading-card .value {
        font-size: 1.2rem;
    }

    /* Charts smaller on mobile */
    .chart-container {
        height: 180px;
        padding: 8px;
    }

    /* ── Legend mobile ── */
    .legend {
        bottom: auto;
        top: 10px;
        right: 10px;
        left: auto;
        padding: 6px 10px;
        z-index: 850;
        opacity: 0.92;
    }

    .legend-bar {
        width: 100px;
        height: 8px;
    }

    .legend-title {
        font-size: 0.6rem;
        margin-bottom: 4px;
    }

    .legend-labels {
        font-size: 0.6rem;
    }

    /* ── Forecast panel mobile: full width, taller ── */
    .forecast-panel {
        width: calc(100% - 16px);
        left: 8px;
        right: 8px;
        bottom: 8px;
        transform: none;
        max-height: 55vh;
        border-radius: 8px;
    }

    .forecast-header {
        padding: 10px 14px;
        gap: 8px;
        flex-wrap: wrap;
    }

    .forecast-header h3 {
        font-size: 0.82rem;
    }

    .forecast-source {
        font-size: 0.65rem;
    }

    .forecast-body {
        padding: 10px 12px;
    }

    /* Forecast charts: single column on mobile */
    .forecast-charts {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .forecast-chart-wrap {
        height: 140px;
    }

    .forecast-chart-wrap canvas {
        height: 110px !important;
    }

    /* ── Stations modal mobile ── */
    .stations-modal {
        width: calc(100vw - 24px);
        max-height: 80vh;
        border-radius: 10px;
    }

    .station-status-item {
        padding: 10px 0;
        font-size: 0.85rem;
    }

    /* ── Prediction cards mobile ── */
    .prediction-card {
        padding: 10px 12px;
    }

    .pred-bar-wrap {
        margin: 0 8px;
    }

    /* ── Leaflet controls ── */
    .leaflet-control-zoom a {
        width: 36px !important;
        height: 36px !important;
        line-height: 36px !important;
        font-size: 18px !important;
    }

    /* ── Station markers smaller on mobile ── */
    .station-marker {
        font-size: 0.7rem;
        padding: 2px 5px;
    }

    .station-marker .name {
        font-size: 0.55rem;
    }

    /* Disable hover tooltips on mobile (use click instead) */
    .station-tooltip-container {
        display: none !important;
    }
}

/* ============================================================
   RESPONSIVO — Tablet (641px - 900px)
   ============================================================ */

@media (min-width: 641px) and (max-width: 900px) {
    .header {
        padding: 8px 12px;
        gap: 4px;
    }

    .header-left {
        gap: 8px;
    }

    .controls {
        gap: 6px;
    }

    .logo-img {
        height: 26px;
    }

    .var-select {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        font-size: 0.95rem;
    }

    .header-clock {
        font-size: 0.75rem;
        padding: 3px 7px;
    }

    .status-btn {
        padding: 4px 8px;
    }

    .status-text {
        font-size: 0.7rem;
    }

    .sidebar {
        width: 340px;
        right: -340px;
    }
}

/* ============================================================
   RESPONSIVO — Telas muito pequenas (max-width: 380px)
   ============================================================ */

@media (max-width: 380px) {
    .header-left {
        gap: 6px;
    }

    .logo-img {
        height: 22px;
    }

    .var-select {
        font-size: 0.78rem;
        padding: 6px 8px;
    }

    .reading-card .value {
        font-size: 1rem;
    }

    .reading-card .label {
        font-size: 0.65rem;
    }

    .legend-bar {
        width: 110px;
    }

    .forecast-panel {
        max-height: 60vh;
    }
}

/* ============================================================
   RESPONSIVO — Landscape mobile
   ============================================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .header {
        min-height: 40px;
        padding: 4px 12px;
    }

    .logo-img {
        height: 22px;
    }

    .sidebar {
        width: 50%;
    }

    .forecast-panel {
        max-height: 65vh;
    }

    .chart-container {
        height: 150px;
    }
}


/* ==================== HEXA CHAT ==================== */

.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #0097a7);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 188, 212, 0.4);
    z-index: 2000;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 188, 212, 0.6);
}

.chat-fab.hidden { display: none; }

.chat-window {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s, transform 0.2s;
}

.chat-window.hidden {
    display: none;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--accent), #0097a7);
    color: #fff;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.chat-header-title .chat-logo {
    font-size: 20px;
}

.chat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0 4px;
}

.chat-close:hover { opacity: 1; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    max-height: 380px;
}

.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-message.system {
    align-self: center;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
    text-align: center;
}

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: chatTyping 1.4s infinite;
}

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

@keyframes chatTyping {
    0%, 100% { opacity: 0.3; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--accent);
}

.chat-input::placeholder {
    color: var(--text-secondary);
}

.chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chat-send:hover {
    background: var(--accent-hover);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile */
@media (max-width: 600px) {
    .chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 16px 16px 0 0;
    }

    .chat-fab {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
}
