/**
 * CityAlerts Frontend Styles
 * Author: Tobalt — https://tobalt.lt
 */

:root {
    --tobalt-icon-color: #0073aa;
    --tobalt-panel-width: 400px;
}

/* Wrapper */
.tobalt-city-alerts-wrapper {
    position: fixed;
    z-index: 999999;
    top: 0;
    bottom: 0;
    pointer-events: none;
}

.tobalt-city-alerts-wrapper.tobalt-position-right {
    right: 0;
}

.tobalt-city-alerts-wrapper.tobalt-position-left {
    left: 0;
}

/* Floating Trigger Button */
.tobalt-alerts-trigger {
    position: fixed;
    bottom: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--tobalt-icon-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
    pointer-events: auto;
    z-index: 999999;
}

.tobalt-position-right .tobalt-alerts-trigger {
    right: 20px;
}

.tobalt-position-left .tobalt-alerts-trigger {
    left: 20px;
}

.tobalt-alerts-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.tobalt-alerts-trigger:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.tobalt-alerts-trigger.is-active {
    background: #333;
}

.tobalt-alerts-trigger svg {
    width: 24px;
    height: 24px;
}

/* Blinking Red Dot (when has alerts) */
.tobalt-alert-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #f44336;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: tobalt-blink 1.5s ease-in-out infinite;
}

@keyframes tobalt-blink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.9);
    }
}

/* Always visible tooltip when has alerts - above the button */
.tobalt-alert-tooltip {
    position: absolute;
    bottom: 65px;
    white-space: nowrap;
    background: #2563eb;
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
    pointer-events: none;
}

/* Right position - tooltip aligned to right edge */
.tobalt-position-right .tobalt-alert-tooltip {
    right: 0;
}

.tobalt-position-right .tobalt-alert-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 18px;
    border: 6px solid transparent;
    border-top-color: #2563eb;
    border-bottom: none;
}

/* Left position - tooltip aligned to left edge */
.tobalt-position-left .tobalt-alert-tooltip {
    left: 0;
}

.tobalt-position-left .tobalt-alert-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 18px;
    border: 6px solid transparent;
    border-top-color: #2563eb;
    border-bottom: none;
}

/* Panel Backdrop */
.tobalt-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    z-index: 999998;
}

/* Panel - 50% height, rounded, centered vertically */
.tobalt-alerts-panel {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    height: 50vh;
    min-height: 300px;
    max-height: 600px;
    width: var(--tobalt-panel-width);
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    z-index: 999999;
    overflow: hidden;
}

.tobalt-position-right .tobalt-alerts-panel {
    right: 20px;
}

.tobalt-position-left .tobalt-alerts-panel {
    left: 20px;
}

/* Panel Header */
.tobalt-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--tobalt-icon-color);
    color: #fff;
    border-radius: 16px 16px 0 0;
}

.tobalt-panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.tobalt-panel-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.tobalt-panel-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Date Navigation */
.tobalt-date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #e5e5e5;
}

.tobalt-nav-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.tobalt-nav-btn:hover:not(:disabled) {
    background: #e5e5e5;
    border-color: #ccc;
}

.tobalt-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tobalt-current-date {
    font-weight: 600;
    color: #1d2327;
}

/* Category Filter */
.tobalt-category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 15px;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
}

.tobalt-filter-btn {
    background: #f0f0f1;
    border: 1px solid #e5e5e5;
    color: #50575e;
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.tobalt-filter-btn:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

.tobalt-filter-btn.is-active {
    background: var(--tobalt-icon-color);
    border-color: var(--tobalt-icon-color);
    color: #fff;
}

/* Alerts List */
.tobalt-alerts-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Loading */
.tobalt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #646970;
}

.tobalt-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e5e5;
    border-top-color: var(--tobalt-icon-color);
    border-radius: 50%;
    animation: tobalt-spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

/* No Alerts */
.tobalt-no-alerts {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #646970;
}

.tobalt-no-alerts svg {
    opacity: 0.3;
    margin-bottom: 15px;
}

.tobalt-no-alerts p {
    margin: 0;
    font-size: 14px;
}

/* Alert Item */
.tobalt-alert-item {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    position: relative;
}

.tobalt-alert-item.is-pinned {
    border-color: var(--tobalt-icon-color);
    background: linear-gradient(135deg, rgba(0, 115, 170, 0.03) 0%, #fff 100%);
}

.tobalt-alert-item:last-child {
    margin-bottom: 0;
}

/* Pinned Badge */
.tobalt-pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--tobalt-icon-color);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

/* Severity Badge */
.tobalt-severity-badge {
    display: inline-block;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    margin-left: 6px;
}

/* Alert Title */
.tobalt-alert-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
    line-height: 1.3;
}

/* Alert Meta */
.tobalt-alert-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #646970;
}

.tobalt-alert-date,
.tobalt-alert-end-date,
.tobalt-alert-location {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tobalt-alert-date {
    color: #2563eb;
}

.tobalt-alert-end-date {
    color: #059669;
}

.tobalt-alert-meta svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.tobalt-alert-meta strong {
    font-weight: 600;
}

/* Alert Description */
.tobalt-alert-description {
    font-size: 13px;
    color: #50575e;
    line-height: 1.5;
}

.tobalt-alert-description p {
    margin: 0 0 8px;
}

.tobalt-alert-description p:last-child {
    margin-bottom: 0;
}

/* Categories */
.tobalt-alert-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tobalt-category-tag {
    background: #f0f0f1;
    color: #646970;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Animations */
.tobalt-fade-enter {
    transition: opacity 0.3s ease-out;
}

.tobalt-fade-leave {
    transition: opacity 0.2s ease-in;
}

[x-cloak] {
    display: none !important;
}

/* Slide animations - Right */
.tobalt-position-right .tobalt-slide-enter {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-out;
}

.tobalt-position-right .tobalt-slide-enter-start {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
}

.tobalt-position-right .tobalt-slide-enter-end {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

.tobalt-position-right .tobalt-slide-leave {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease-in;
}

.tobalt-position-right .tobalt-slide-leave-start {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

.tobalt-position-right .tobalt-slide-leave-end {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
}

/* Slide animations - Left */
.tobalt-position-left .tobalt-slide-enter {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease-out;
}

.tobalt-position-left .tobalt-slide-enter-start {
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
}

.tobalt-position-left .tobalt-slide-enter-end {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

.tobalt-position-left .tobalt-slide-leave {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease-in;
}

.tobalt-position-left .tobalt-slide-leave-start {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

.tobalt-position-left .tobalt-slide-leave-end {
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
}

/* Inline Panel */
.tobalt-city-alerts-inline {
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}

.tobalt-city-alerts-inline .tobalt-date-nav {
    border-radius: 16px 16px 0 0;
}

.tobalt-city-alerts-inline .tobalt-alerts-list {
    max-height: 500px;
}

/* Mobile */
@media (max-width: 480px) {
    .tobalt-alerts-panel {
        width: calc(100vw - 20px);
        max-width: none;
        right: 10px;
        left: 10px;
        height: 60vh;
    }

    .tobalt-position-right .tobalt-alerts-panel,
    .tobalt-position-left .tobalt-alerts-panel {
        right: 10px;
        left: 10px;
    }

    .tobalt-alerts-trigger {
        bottom: 15px;
    }

    .tobalt-position-right .tobalt-alerts-trigger {
        right: 15px;
    }

    .tobalt-position-left .tobalt-alerts-trigger {
        left: 15px;
    }
}
