/* ========== COLLAPSIBLE SIDEBAR STYLES ========== */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    --sidebar-hover: rgba(255,255,255,0.1);
    --sidebar-active: rgba(67, 97, 238, 0.3);
    --transition-speed: 0.3s;
}

/* Sidebar Base */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: var(--sidebar-bg);
    color: white;
    z-index: 1040;
    transition: width var(--transition-speed) ease;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 70px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--transition-speed);
}

.sidebar.collapsed .sidebar-brand span {
    display: none;
}

.sidebar-brand i {
    font-size: 1.5rem;
    min-width: 24px;
    text-align: center;
}

/* Toggle Button */
.sidebar-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.2);
}

.sidebar.collapsed .sidebar-toggle i::before {
    content: "\f105" !important; /* FontAwesome right arrow */
}

/* Sidebar Navigation */
.sidebar-nav {
    padding: 10px 0;
    list-style: none;
    margin: 0;
}

.sidebar-item {
    margin: 2px 10px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    gap: 12px;
}

.sidebar-link:hover,
.sidebar-link.active {
    color: white;
    background: var(--sidebar-hover);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    border-left: 3px solid #4361ee;
}

.sidebar-link i {
    font-size: 1.1rem;
    min-width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-link span,
.sidebar.collapsed .sidebar-text {
    display: none !important;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .sidebar-link i {
    margin: 0;
}

/* Dropdown/Submenu */
.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease;
    background: rgba(0,0,0,0.1);
    border-radius: 0 0 8px 8px;
}

.sidebar-submenu.show {
    max-height: 500px; /* Adjust based on content */
}

.sidebar-submenu .sidebar-link {
    padding-left: 55px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
}

.sidebar-submenu .sidebar-link:hover,
.sidebar-submenu .sidebar-link.active {
    color: white;
    background: rgba(255,255,255,0.05);
}

.sidebar.collapsed .sidebar-submenu {
    display: none !important;
}

/* Dropdown Toggle Arrow */
.sidebar-link.has-submenu::after {
    content: "\f107";
    font-family: "Bootstrap Icons";
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.9rem;
}

.sidebar-link.has-submenu[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-link.has-submenu::after {
    display: none;
}

/* User Profile Section */
.sidebar-user {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-speed);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #4361ee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
}

.sidebar.collapsed .sidebar-user-info {
    display: none;
}

.sidebar.collapsed .sidebar-user {
    justify-content: center;
    padding: 15px;
}

/* Main Content Adjustment */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Overlay for Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    
    .sidebar.mobile-show {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed + .main-content {
        margin-left: 0;
    }
    
    /* Show toggle button on mobile */
    .mobile-toggle {
        display: flex !important;
    }
}

.mobile-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1050;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Tooltip for collapsed state */
.sidebar.collapsed .sidebar-link[title] {
    position: relative;
}

.sidebar.collapsed .sidebar-link[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 10px;
    padding: 5px 10px;
    background: #333;
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Purple badge for rescheduled status */
.bg-purple {
    background-color: #8b5cf6 !important;
    color: white !important;
}

/* Skill match indicator in technician dropdown */
select option[data-skills]:not([data-skills=""]) {
    font-weight: 500;
}

/* Smooth transitions for table rows */
.table tbody tr {
    transition: background-color 0.15s ease;
}

/* Loading spinner for buttons */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Responsive table tweaks */
@media (max-width: 768px) {
    .table-responsive {
        font-size: 0.85rem;
    }
    .table th, .table td {
        padding: 0.5rem !important;
    }
    .btn-group .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Form validation feedback */
.form-control.is-invalid, .form-select.is-invalid {
    border-color: #dc3545;
    background-image: url("data:image/svg+xml,..."); /* Bootstrap default */
}

/* Date/time picker enhancement */
input[type="datetime-local"] {
    min-width: 200px;
}

/* Badge hover effect */
.badge {
    transition: transform 0.15s ease;
}
.badge:hover {
    transform: scale(1.05);
}

/* Timeline Styles */
.timeline {
    position: relative;
    padding-left: 30px;
    margin: 20px 0;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
    display: flex;
    gap: 15px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
}

.timeline-marker i {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border: 3px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.timeline-item.active .timeline-marker i {
    background: #3b82f6;
    color: #fff;
}

.timeline-item.current .timeline-marker i {
    background: #22c55e;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(34,197,94,0.2);
    transform: scale(1.1);
}

.timeline-connector {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: calc(100% + 20px);
    background: #e9ecef;
    transition: background 0.2s ease;
}

.timeline-item.active + .timeline-item .timeline-connector {
    background: #3b82f6;
}

.timeline-content {
    flex: 1;
    padding-top: 4px;
}

.timeline-title {
    font-weight: 600;
    color: #1a2340;
    margin-bottom: 2px;
}

.timeline-item.active .timeline-title {
    color: #3b82f6;
}

.timeline-item.current .timeline-title {
    color: #22c55e;
}

/* Status Badges */
.badge-assigned { background-color: #0ea5e9 !important; }
.badge-accepted { background-color: #3b82f6 !important; }
.badge-rejected { background-color: #ef4444 !important; }
.badge-in_progress { background-color: #f59e0b !important; color: #000 !important; }
.badge-completed { background-color: #22c55e !important; }
.badge-rescheduled { background-color: #8b5cf6 !important; }

/* Action Button States */
.btn-action {
    transition: all 0.15s ease;
}
.btn-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* OTP Display */
.otp-display {
    font-family: 'DM Mono', monospace;
    letter-spacing: 8px;
    font-weight: 600;
}

/* Location Card */
.location-card {
    border-left: 4px solid #ef4444;
}
.location-card.completed {
    border-left-color: #22c55e;
}

/* Responsive Timeline */
@media (max-width: 768px) {
    .timeline {
        padding-left: 20px;
    }
    .timeline-marker i {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    .timeline-connector {
        left: 12px;
    }
}

/* Print Styles */
@media print {
    .no-print, .btn, .modal, .sidebar, .topbar {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
        padding: 20px !important;
    }
    .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    .timeline-connector {
        display: none;
    }
}