/* Store Plans Table Specific Styles */

body {
    overflow-y: auto;
    overflow-x: hidden;
}

.store-plans-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: fixed;
}

.store-plans-table th,
.store-plans-table td {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.store-plans-table thead th {
    border-bottom: 2px solid rgba(0, 0, 0, 0.15);
}

.store-plans-table .work-header-cell {
    width: 120px;
    background: white;
    border-right: 2px solid rgba(0, 0, 0, 0.15);
}

.store-plans-table .work-day-cell {
    width: calc((100% - 120px) / 7);
}

.store-plans-table .work-data-cell {
    padding: 0.4rem;
    vertical-align: top;
    position: relative;
}

.store-plans-table .work-truck-cell {
    border-right: 2px solid rgba(0, 0, 0, 0.15);
    vertical-align: middle;
}

.plan-cell {
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.plan-cell-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.2rem;
}

.btn-toggle-holiday {
    font-size: 0.65rem;
    padding: 0.25rem 0.45rem;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1.5px solid #28a745;
    background: white;
    color: #28a745;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-share-location {
    font-size: 0.65rem;
    padding: 0.25rem 0.4rem;
    border-radius: 50%;
    transition: all 0.3s ease;
    /* border: 1.5px solid #0d6efd; */
    background: white;
    color: #0d6efd;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    cursor: pointer;
}

.btn-share-location:hover {
    background: #0d6efd;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

.btn-share-location i {
    font-size: 0.7rem;
}

.btn-toggle-holiday:hover {
    background: #28a745;
    color: white;
    transform: scale(1.05);
}

.btn-toggle-holiday.btn-outline-danger {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-toggle-holiday.btn-outline-danger:hover {
    background: #dc3545;
    color: white;
}

.btn-toggle-holiday i {
    font-size: 0.7rem;
}

.btn-toggle-holiday .status-text {
    font-weight: 500;
}

.btn-add-plan-floating {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 10;
}

.btn-add-plan-floating:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.6);
}

.btn-add-plan-floating i {
    font-size: 0.75rem;
}

/* Holiday state */
.work-data-cell.is-holiday {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
}

.work-data-cell.is-holiday .plan-items {
    opacity: 0.6;
}

.work-data-cell.is-holiday .btn-add-plan-floating {
    display: none;
}

.plan-items {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0;
}

.plan-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e9ecef;
    border-left: 3px solid #007bff;
    padding: 0.35rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: pointer;
}

.plan-item:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.plan-item.type-store_top500 {
    border-left-color: #007bff;
}

.plan-item.type-store_ob {
    border-left-color: #fd7e14;
}

.plan-item.type-store_collect {
    border-left-color: #17a2b8;
}

.plan-item.type-rest_point {
    border-left-color: #6f42c1;
}

.plan-item.type-mall_warehouse {
    border-left-color: #e83e8c;
}

.plan-item.type-branch_warehouse {
    border-left-color: #20c997;
}

/* Special styling for Ubon Ratchathani branch warehouse */
.plan-item.type-branch_warehouse.ubon-warehouse {
    background: linear-gradient(135deg, #fff9e6 0%, #ffe6b3 100%);
    border-left-color: #ffc107;
    border-left-width: 4px;
}

.plan-item.type-branch_warehouse.ubon-warehouse:hover {
    background: linear-gradient(135deg, #ffe6b3 0%, #ffd480 100%);
    box-shadow: 0 3px 8px rgba(255, 193, 7, 0.3);
}

.plan-item.type-branch_warehouse.ubon-warehouse .plan-item-line1 {
    color: #856404;
    font-weight: 700;
}

.plan-item.type-branch_warehouse.ubon-warehouse .plan-item-line2 {
    color: #856404;
}

/* Completed item styling */
.plan-item.plan-item-completed {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    /* border-left keeps its type color */
}

/* When Ubon warehouse is completed, override with green */
.plan-item.type-branch_warehouse.ubon-warehouse.plan-item-completed {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left-color: #28a745;
}

.plan-item.type-branch_warehouse.ubon-warehouse.plan-item-completed .plan-item-line1 {
    color: #155724;
    font-weight: 600;
}

.plan-item.type-branch_warehouse.ubon-warehouse.plan-item-completed .plan-item-line2 {
    color: #155724;
}

.plan-item.type-branch_warehouse.ubon-warehouse.plan-item-completed:hover {
    background: linear-gradient(135deg, #c3e6cb 0%, #b1dfbb 100%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.plan-item.plan-item-completed .plan-item-line1 {
    color: #155724;
}

.plan-item.plan-item-completed .plan-item-line2 {
    color: #155724;
}

.plan-item.plan-item-completed:hover {
    background: linear-gradient(135deg, #c3e6cb 0%, #b1dfbb 100%);
}

.plan-item-line1 {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.15rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    line-height: 1.2;
}

.plan-item-line1 i {
    font-size: 0.7rem;
    flex-shrink: 0;
}

.plan-item-line1 .item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-item-line1 .item-time {
    font-weight: 700;
    color: #fd7e14;
    flex-shrink: 0;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: rgba(253, 126, 20, 0.1);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
}

.plan-item-line1 .item-quantity {
    font-weight: 700;
    color: #28a745;
    flex-shrink: 0;
    margin-left: 0.3rem;
}

.plan-item-line2 {
    font-size: 0.7rem;
    color: #6c757d;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Truck cell styling */
.work-truck-cell {
    padding: 0.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    font-weight: 600;
    height: 100%;
}

.work-truck-cell > div {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
}

.truck-badge {
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.truck-info {
    display: flex;
    flex-direction: column;
}

.truck-name {
    font-size: 0.8rem;
    color: #2c3e50;
    font-weight: 600;
}

.truck-code {
    font-size: 0.7rem;
    color: #6c757d;
    font-weight: 400;
}

/* Modal customizations */
.btn-group-type-select {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.btn-group-type-select .btn-outline-primary {
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-group-type-select .btn-outline-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.2);
}

.btn-group-type-select .btn-check:checked + .btn-outline-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white;
    border-color: #0d6efd;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Responsive table */
@media (max-width: 1400px) {
    .store-plans-table {
        font-size: 0.85rem;
    }

    .work-day-cell {
        min-width: 140px;
    }

    .plan-cell .btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.4rem;
    }
}

@media (max-width: 992px) {
    .work-table-container {
        overflow-x: auto;
    }

    .store-plans-table {
        min-width: 1200px;
    }

    .work-header {
        flex-direction: column;
        gap: 1rem;
    }

    .work-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Loading state */
.plan-cell.loading {
    opacity: 0.6;
    pointer-events: none;
}

.plan-cell.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Empty state */
.plan-items-empty {
    text-align: center;
    color: #adb5bd;
    font-size: 0.7rem;
    padding: 0.5rem 0;
    font-style: italic;
}

/* Hover effects for cells */
.work-data-cell {
    transition: background-color 0.2s ease;
}

.work-data-cell:hover {
    background-color: rgba(0, 123, 255, 0.02);
}

.work-data-cell.weekend:hover {
    background-color: rgba(255, 193, 7, 0.05);
}

/* Confirm Modal Styles */
.item-type-badge {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.selected-item-info {
    border-left: 4px solid #28a745;
}
