// =====================================================================
// Fusion Task Map View - Sidebar + Google Maps
// Theme-aware: uses Odoo/Bootstrap variables for dark mode support
// =====================================================================

$sidebar-width: 340px;
$transition-speed: .25s;

.o_fusion_task_map_view {
    height: 100%;

    .o_content {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
}

// ── Main wrapper: sidebar + map side by side ────────────────────────
.fc_map_wrapper {
    display: flex;
    flex-direction: row;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

// ── Sidebar ─────────────────────────────────────────────────────────
.fc_sidebar {
    width: $sidebar-width;
    min-width: $sidebar-width;
    max-width: $sidebar-width;
    background: var(--o-view-background-color, $o-view-background-color);
    border-right: 1px solid $border-color;
    display: flex;
    flex-direction: column;
    transition: width $transition-speed ease, min-width $transition-speed ease,
                max-width $transition-speed ease, opacity $transition-speed ease;
    overflow: hidden;

    &--collapsed {
        width: 0;
        min-width: 0;
        max-width: 0;
        opacity: 0;
        border-right: none;
    }
}

.fc_sidebar_header {
    padding: 14px 16px 12px;
    border-bottom: 1px solid $border-color;
    flex-shrink: 0;

    h6 {
        font-size: 14px;
        color: $headings-color;
    }
}

.fc_sidebar_body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 0;

    &::-webkit-scrollbar { width: 5px; }
    &::-webkit-scrollbar-track { background: transparent; }
    &::-webkit-scrollbar-thumb { background: $border-color; border-radius: 4px; }
}

.fc_sidebar_footer {
    padding: 10px 16px;
    border-top: 1px solid $border-color;
    flex-shrink: 0;
}

.fc_sidebar_empty {
    text-align: center;
    padding: 40px 20px;
    color: $text-muted;
}

// ── Day filter chips ────────────────────────────────────────────────
.fc_day_filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fc_day_chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid $border-color;
    border-radius: 12px;
    background: transparent;
    color: $text-muted;
    cursor: pointer;
    transition: all .15s;
    line-height: 18px;

    &:hover {
        border-color: rgba($primary, .3);
        color: $body-color;
    }

    &--active {
        color: #fff !important;
        border-color: transparent !important;
    }

    &--all {
        color: $body-color;
        font-weight: 500;
        &:hover { background: rgba($primary, .1); }
    }
}

.fc_day_chip_count {
    font-size: 10px;
    opacity: .8;
}

.fc_group_hidden_tag {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: $text-muted;
    background: rgba($secondary, .1);
    padding: 0 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 500;
}

// ── Technician filter chips ─────────────────────────────────────────
.fc_tech_filters {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fc_tech_chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px 3px 4px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid $border-color;
    border-radius: 14px;
    background: transparent;
    color: $text-muted;
    cursor: pointer;
    transition: all .15s;
    line-height: 18px;
    max-width: 100%;
    overflow: hidden;

    &:hover {
        border-color: rgba($primary, .35);
        color: $body-color;
        background: rgba($primary, .06);
    }

    &--active {
        background: $primary !important;
        color: #fff !important;
        border-color: $primary !important;

        .fc_tech_chip_avatar {
            background: rgba(#fff, .25);
            color: #fff;
        }
    }

    &--all {
        padding: 3px 10px;
        color: $body-color;
        font-weight: 500;
        &:hover { background: rgba($primary, .1); }
    }
}

.fc_tech_chip_avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba($secondary, .15);
    color: $body-color;
    font-size: 9px;
    font-weight: 700;
    flex-shrink: 0;
}

.fc_tech_chip_name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

// Collapsed toggle button (floating)
.fc_sidebar_toggle_btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    background: var(--o-view-background-color, $o-view-background-color);
    border: 1px solid $border-color;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 12px 6px;
    cursor: pointer;
    box-shadow: 2px 0 6px rgba(0,0,0,.08);
    color: $text-muted;
    transition: background .15s;

    &:hover {
        background: $o-gray-100;
        color: $body-color;
    }
}

// ── Group headers ───────────────────────────────────────────────────
.fc_group_header {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 12px;
    color: $text-muted;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: rgba($secondary, .08);
    border-bottom: 1px solid $border-color;
    transition: background .15s;

    &:hover {
        background: rgba($secondary, .15);
    }

    .fa-caret-right,
    .fa-caret-down {
        width: 14px;
        text-align: center;
        font-size: 13px;
    }
}

.fc_group_label {
    flex: 1;
}

.fc_group_badge {
    background: rgba($secondary, .2);
    color: $body-color;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

// ── Task cards ──────────────────────────────────────────────────────
.fc_group_tasks {
    padding: 4px 0;
}

.fc_task_card {
    margin: 3px 10px;
    padding: 10px 12px;
    background: var(--o-view-background-color, $o-view-background-color);
    border: 1px solid $border-color;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    position: relative;

    &:hover {
        background: rgba($primary, .05);
        border-color: rgba($primary, .2);
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
    }

    &--active {
        background: rgba($primary, .1) !important;
        border-color: rgba($primary, .35) !important;
        box-shadow: 0 0 0 2px rgba($primary, .15);
    }
}

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

.fc_task_num {
    display: inline-block;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 4px;
    line-height: 18px;
}

.fc_task_status {
    font-size: 11px;
    font-weight: 600;
}

.fc_task_client {
    font-size: 13px;
    font-weight: 600;
    color: $headings-color;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc_task_meta {
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: $body-color;
    margin-bottom: 3px;

    .fa { opacity: .5; }
}

.fc_task_detail {
    font-size: 11px;
    color: $body-color;
    margin-bottom: 2px;
    .fa { opacity: .5; }
}

.fc_task_address {
    font-size: 10px;
    color: $text-muted;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.fc_task_bottom_row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.fc_task_travel {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    color: $body-color;
    background: rgba($secondary, .1);
    padding: 1px 8px;
    border-radius: 4px;
    .fa { opacity: .5; }
}

.fc_task_source {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    color: #fff;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 4px;
    .fa { opacity: .8; }
}

.fc_task_edit_btn {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--btn-primary-color, #fff);
    background: var(--btn-primary-bg, #{$primary});
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: auto;
    transition: all .15s;

    &:hover {
        opacity: .85;
        filter: brightness(1.15);
    }
}

// ── Map area ────────────────────────────────────────────────────────
.fc_map_area {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.fc_map_legend_bar {
    flex: 0 0 auto;
    font-size: 12px;
    min-height: 40px;
}

.fc_map_container {
    flex: 1 1 auto;
    position: relative;
    min-height: 400px;
}

// ── Google Maps InfoWindow override ──────────────────────────────────
.gm-style-iw-d {
    overflow: auto !important;
}
.gm-style .gm-style-iw-c {
    padding: 0 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    box-shadow: 0 4px 20px rgba(0,0,0,.15) !important;
}
.gm-style .gm-style-iw-tc {
    display: none !important;
}
.gm-style .gm-ui-hover-effect {
    display: none !important;
}

// ── Responsive ──────────────────────────────────────────────────────
@media (max-width: 768px) {
    .fc_map_wrapper {
        flex-direction: column;
    }
    .fc_sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid $border-color;

        &--collapsed {
            max-height: 0;
            opacity: 0;
        }
    }
    .fc_sidebar_toggle_btn {
        top: auto;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 8px;
        border: 1px solid $border-color;
        padding: 8px 16px;
    }
    .fc_map_area {
        flex: 1;
        min-height: 300px;
    }
}
