/**
 * ========================================
 * PROGRAMARE PAGE - MOBILE FIRST STYLES
 * ========================================
 * Design optimizat pentru mobile (320px+)
 * cu adaptare progresivă pentru tablete și desktop
 */

/* ========================================
   ROOT VARIABLES & PERFORMANCE
   ======================================== */
:root {
    --primary-color: #007bff;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --gray-light: #f8f9fa;
    --gray-medium: #e9ecef;
    --gray-dark: #6c757d;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --box-shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --transition: all 0.3s ease;
}

/* Hardware acceleration pentru animații */
* {
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    -webkit-touch-callout: none;
}

/* Spațiu pentru mobile bottom navigation */
@media (max-width: 991.98px) {
    body {
        padding-bottom: 80px !important;
    }
}

/* Ascunde checkbox-uri SweetAlert2 când nu sunt în modal */
.swal2-checkbox:not(.swal2-container .swal2-checkbox),
label.swal2-checkbox[style*="display: none"] {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

.programare-card,
.status-icon,
.export-btn,
.toggle-option {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* ========================================
   BASE MOBILE STYLES (320px+)
   ======================================== */

/* Container principal */
.container {
    width: 100%;
    padding: 0 8px;
    margin: 0 auto;
}

/* Hartă - mobil */
#mapService {
    height: 250px;
    width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Bară de căutare - mobile first */
.baraCautare {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 10px 0 !important;
    padding: 0 8px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.baraCautareContainer {
    position: relative !important;
    width: 100%;
}

.baraCautareContainer input#searchInput {
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px 12px !important;
    font-size: 16px !important; /* 16px previne zoom pe iOS */
    border-radius: 8px !important;
    border: 1.5px solid #e3e6ea !important;
    background: #fff !important;
    font-weight: 500 !important;
    color: #222 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08) !important;
    outline: none !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    height: 42px !important;
    -webkit-appearance: none; /* Remove iOS styling */
    appearance: none;
}

.baraCautareContainer input#searchInput:focus {
    border-color: #007bff !important;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15) !important;
}

#autocompleteSuggestions {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    width: 100% !important;
    background: #fff !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    border: 1px solid #e3e6ea !important;
    border-top: none !important;
    z-index: 1000 !important;
    display: none;
    max-height: 200px !important;
    overflow-y: auto !important;
    font-size: 15px !important;
    margin-top: 2px;
}

#resultSummary {
    margin-top: 6px !important;
    padding: 0 4px !important;
    font-size: 14px !important;
    color: #b23c3c !important;
    font-weight: 500 !important;
    min-height: 16px !important;
}

#resultSummary p {
    margin: 0 !important;
    line-height: 1.3 !important;
}

/* Bară status clienți - mobile */
.client-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    background: #fff !important;
    padding: 10px 8px;
    margin: 12px 0;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    gap: 8px;
}

.status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f8f9fa !important;
    color: #212529 !important;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    border: 2px solid transparent;
    flex: 1 1 auto;
    min-width: 80px;
    text-align: center;
}

.status-icon:active {
    transform: scale(0.95);
}

.status-icon:hover {
    background: #e9ecef !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
}

.status-icon.active {
    background: #007bff !important;
    color: white !important;
    border-color: #0056b3;
}

.status-icon span {
    background: rgba(255,255,255,0.9);
    color: #333;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    text-align: center;
}

.status-icon.active span {
    background: rgba(255,255,255,0.25);
    color: white;
}

/* Buton Export - mobile */
.export-btn {
    position: relative;
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
    background: #6f42c1;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.export-btn:active {
    transform: scale(0.98);
}

.export-btn.active {
    border-radius: 10px 10px 0 0;
}

#export-arrow {
    transition: transform 0.3s ease;
    font-size: 12px;
}

#export-arrow.rotated {
    transform: rotate(180deg);
}

/* Meniu export - mobile */
.export-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9999;
    max-height: 80vh;
    overflow-y: auto;
}

.export-menu.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.export-menu-content {
    padding: 20px 16px;
}

.export-section {
    margin-bottom: 20px;
}

.export-section h4 {
    color: #6f42c1;
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.export-buttons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.export-option {
    padding: 10px 12px;
    border: 2px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-option:active {
    transform: scale(0.95);
}

.export-option.active {
    background: #6f42c1;
    color: white;
    border-color: #6f42c1;
}

.export-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.export-execute-btn,
.export-cancel-btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.export-execute-btn {
    background: #28a745;
    color: white;
}

.export-execute-btn:active {
    transform: scale(0.98);
}

.export-cancel-btn {
    background: #6c757d;
    color: white;
}

.export-cancel-btn:active {
    transform: scale(0.98);
}

/* Calendar - mobile */
.calendar-container {
    width: 100%;
    padding: 12px 8px;
    margin-top: 16px;
}

.calendar-container h2#currentMonth {
    font-size: 18px;
    margin: 10px 0;
    text-align: center;
    font-weight: 600;
    color: #333;
}

.calendar {
    width: 100%;
    background: white;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.btn-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    justify-content: center;
}

.btn-group button {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
    border-radius: 8px;
    font-weight: 500;
    white-space: nowrap;
}

/* Container carduri - mobile: scroll unic al paginii (fara scroll intern pe lista de carduri) */
#cardContainer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0 12px 16px;
    margin-top: 16px;
    scroll-snap-type: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
    height: auto !important;
    max-height: none !important;
    scroll-behavior: auto;
    -webkit-overflow-scrolling: auto;
    overscroll-behavior: auto;
}

.programare-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #f0f0f0;
    scroll-snap-align: none;
    scroll-margin-top: 0;
}

/* Defensive override: daca modulul de performanta adauga virtual scroll, il anulam pentru Programari */
#cardContainer.virtual-scroll-container {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
    position: static !important;
}

/* Override global .card/.card-body rules from shared styles to keep Programari cards stable */
#cardContainer .programare-card {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

#cardContainer .programare-card .programare-card-body {
    display: block !important;
    flex-direction: initial !important;
    justify-content: initial !important;
    align-items: initial !important;
    padding: 20px !important;
}

#cardContainer .programare-card .programare-card-text {
    display: block !important;
    margin: 0 !important;
}

#cardContainer .programare-card button,
#cardContainer .programare-card select,
#cardContainer .programare-card input[type="checkbox"] {
    margin: 0 !important;
}

.programare-card:active {
    transform: scale(0.98);
}

.programare-card.filtered-out {
    opacity: 0.3;
    transform: scale(0.95);
}

/* Ascunde controalele de zoom din hărți Leaflet, dar păstrează layer control */
.leaflet-control-zoom,
.leaflet-control-attribution {
    display: none !important;
}

/* Afișează controlul de layers */
.leaflet-control-layers {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Optimizări pentru conținutul cardurilor pe mobile */
.programare-card .client-name {
    font-size: 16px;
    font-weight: 600;
    color: #212529;
    margin-bottom: 6px;
    line-height: 1.3;
}

.programare-card .client-phone {
    font-size: 15px;
    color: #007bff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.programare-card .client-phone::before {
    content: "📞";
    font-size: 14px;
}

.programare-card .client-address {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.4;
}

.programare-card .client-address::before {
    content: "📍";
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
}

.programare-card .info-text {
    font-size: 13px;
    color: #495057;
    margin-bottom: 10px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.programare-card .appointment-date,
.programare-card .team-display,
.programare-card .price-display {
    font-size: 14px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.programare-card .appointment-date {
    color: #28a745;
    font-weight: 500;
}

.programare-card .appointment-date::before {
    content: "📅";
    font-size: 14px;
}

.programare-card .team-display {
    color: #6f42c1;
}

.programare-card .team-display::before {
    content: "👥";
    font-size: 14px;
}

.programare-card .price-display {
    color: #17a2b8;
    font-weight: 600;
}

.programare-card .price-display::before {
    content: "💰";
    font-size: 14px;
}

/* Butoane acțiuni în carduri - mobile optimized */
.programare-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.programare-card .card-actions button,
.programare-card .card-actions .btn {
    flex: 1 1 auto;
    min-width: 100px;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 6px;
    white-space: nowrap;
}

/* Butoane Maps/Waze - mobile optimized */
.case-card__map-buttons {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.case-card__map-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #4285f4, #3367d6);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 3px 8px rgba(66, 133, 244, 0.35);
    transition: all 0.2s ease;
    flex: 1;
    min-width: 110px;
}

.case-card__map-btn:hover,
.case-card__map-btn:active {
    background: linear-gradient(135deg, #3367d6, #2851a3);
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.45);
}

.case-card__map-btn i {
    font-size: 16px;
}

.case-card__map-btn--waze {
    background: linear-gradient(135deg, #33ccff, #00b8e6);
    box-shadow: 0 3px 8px rgba(51, 204, 255, 0.35);
}

.case-card__map-btn--waze:hover,
.case-card__map-btn--waze:active {
    background: linear-gradient(135deg, #00b8e6, #0099cc);
    box-shadow: 0 4px 12px rgba(51, 204, 255, 0.45);
}

/* Indicator status apel */
.call-status-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: #6c757d;
    z-index: 2;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.call-status-indicator.programat { background: #28a745; }
.call-status-indicator.anulat { background: #dc3545; }
.call-status-indicator.nu_raspunde { background: #ffc107; color: #212529; }
.call-status-indicator.in_asteptare { background: #17a2b8; }
.call-status-indicator.numar_gresit { background: #fd7e14; }
.call-status-indicator.refuzat { background: #6c757d; }

/* Modals - mobile optimized */
.modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
}

.modal-content {
    border-radius: 12px;
}

.modal-header {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #e9ecef;
}

.form-control {
    font-size: 16px !important; /* Previne zoom pe iOS */
    padding: 10px 12px;
    border-radius: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #495057;
}

/* Toggle script - mobile */
.script-toggle-container {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    padding: 0 8px;
}

.toggle-pill {
    position: relative;
    display: flex;
    background: #f8f9fa;
    border-radius: 50px;
    padding: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    overflow: hidden;
    width: 100%;
    max-width: 320px;
}

.toggle-option {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 46px;
    transition: all 0.3s ease;
    z-index: 2;
    flex: 1;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #6c757d;
}

.toggle-option:active {
    transform: scale(0.95);
}

.toggle-option.active {
    color: #ffffff;
}

.toggle-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 46px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    z-index: 1;
}

.toggle-pill[data-active="programareNou"] .toggle-slider {
    transform: translateX(100%);
    background: linear-gradient(135deg, #28a745, #1e7e34);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Status bar */
.status-bar {
    display: flex;
    gap: 10px;
    padding: 10px 8px;
    margin: 12px 0;
}

.status-item {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.status-item:active {
    transform: scale(0.95);
}

.status-item.green {
    background: #28a745;
    color: white;
}

.status-item.red {
    background: #dc3545;
    color: white;
}

/* ========================================
   TABLET STYLES (600px+)
   ======================================== */
@media (min-width: 600px) {
    .container {
        padding: 0 16px;
    }

    #mapService {
        height: 350px;
        margin-bottom: 16px;
    }

    .baraCautare {
        width: max-content !important;
        max-width: 500px !important;
        margin: 16px auto 12px auto !important;
        padding: 0 !important;
    }

    .baraCautareContainer input#searchInput {
        width: 400px !important;
        max-width: 500px !important;
        font-size: 15px !important;
        height: 38px !important;
    }

    #autocompleteSuggestions {
        font-size: 14px !important;
        max-height: 250px !important;
    }

    #resultSummary {
        font-size: 13px !important;
    }

    .client-status-bar {
        padding: 12px 16px;
        gap: 12px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .status-icon {
        flex: 0 0 auto;
        min-width: 100px;
    }

    .export-btn {
        width: auto;
        margin-left: auto;
        margin-top: 0;
    }

    .export-menu {
        position: absolute;
        bottom: auto;
        top: 100%;
        left: auto;
        right: 0;
        border-radius: 0 0 20px 20px;
        max-height: none;
        min-width: 450px;
        max-width: 600px;
    }

    .export-menu-content {
        padding: 24px;
    }

    .export-buttons-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .export-actions {
        flex-direction: row;
    }

    .export-execute-btn {
        flex: 1;
    }

    .export-cancel-btn {
        flex: 0 0 auto;
        min-width: 120px;
    }

    #cardContainer {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 0 16px 24px;
        align-items: start;
    }

    .calendar-container {
        padding: 16px;
    }

    .calendar-container h2#currentMonth {
        font-size: 22px;
    }

    .btn-group {
        flex-direction: row;
        justify-content: center;
        gap: 12px;
    }

    .btn-group button {
        width: auto;
        min-width: 180px;
        padding: 10px 20px;
    }

    .toggle-pill {
        width: auto;
        max-width: none;
    }

    .toggle-option {
        min-width: 160px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .toggle-slider {
        width: 160px;
    }

    .toggle-pill[data-active="programareNou"] .toggle-slider {
        transform: translateX(160px);
    }
}

/* ========================================
   DESKTOP STYLES (992px+)
   ======================================== */
@media (min-width: 992px) {
    .container {
        max-width: 1200px;
        padding: 0 24px;
    }

    #mapService {
        height: 500px;
        margin-bottom: 20px;
    }

    .baraCautare {
        margin: 20px auto 16px auto !important;
    }

    .client-status-bar {
        padding: 15px 20px;
        gap: 15px;
    }

    .status-icon {
        padding: 10px 15px;
        font-size: 14px;
    }

    .export-menu {
        min-width: 500px;
    }

    .export-buttons-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    #cardContainer {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 0 24px 32px;
        align-items: start;
    }

    .calendar-container {
        padding: 24px;
    }

    .calendar-container h2#currentMonth {
        font-size: 24px;
        margin: 16px 0;
    }

    .modal-dialog {
        margin: 30px auto;
        max-width: 600px;
    }
}

/* ========================================
   LARGE DESKTOP STYLES (1200px+)
   ======================================== */
@media (min-width: 1200px) {
    .container {
        max-width: 1400px;
    }

    #cardContainer {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .export-buttons-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

/* Touch-friendly hover effects */
@media (hover: hover) and (pointer: fine) {
    .status-icon:hover {
        background: #e9ecef;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .export-btn:hover {
        background: #5a32a3;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .export-option:hover {
        border-color: #6f42c1;
        background: #f3f0ff;
        transform: translateY(-1px);
    }

    .export-execute-btn:hover {
        background: #218838;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    }

    .export-cancel-btn:hover {
        background: #5a6268;
        transform: translateY(-2px);
    }

    .programare-card:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,0.12);
        transform: translateY(-2px);
    }
}

/* Smooth scrolling - DEZACTIVAT pentru admin pages pentru a preveni scroll automat */
html {
    scroll-behavior: auto; /* Changed from smooth - causes auto-scroll issues on admin dashboards */
}

/* Re-enable smooth scroll only for anchor links via JS if needed */
html.smooth-scroll-enabled {
    scroll-behavior: smooth;
}

/* Safe area pentru notch (iPhone X+) */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    .export-menu {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Dark mode support (opțional) */
@media (prefers-color-scheme: dark) {
    /* Aici poți adăuga stiluri pentru dark mode dacă este necesar */
}

/* Print styles */
@media print {
    .client-status-bar,
    .export-btn,
    .btn-group,
    .script-toggle-container {
        display: none !important;
    }

    #mapService {
        height: 400px;
        page-break-inside: avoid;
    }

    .programare-card {
        page-break-inside: avoid;
    }
}

/* ========================================
   NAVBAR OPTIMIZATIONS FOR MOBILE
   ======================================== */

/* Navbar base styles */
.navbar {
    padding: 8px 12px;
}

.navbar-brand {
    font-size: 18px;
    padding: 8px 0;
}

.navbar-toggler {
    padding: 6px 10px;
    font-size: 18px;
    border-radius: 6px;
}

.navbar-nav .nav-link {
    padding: 10px 16px;
    font-size: 15px;
}

/* Dropdown menu pentru mobile */
.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid #e9ecef;
}

.dropdown-item {
    padding: 10px 16px;
    font-size: 15px;
}

.dropdown-item:active {
    background-color: #007bff;
}

/* Button optimizations pentru mobile */
.btn {
    padding: 10px 16px;
    font-size: 15px;
    border-radius: 8px;
    font-weight: 500;
    touch-action: manipulation; /* Previne double-tap zoom */
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 17px;
}

/* Touch-friendly tap areas */
button, a, .clickable {
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
}

/* Lista utilizatori/echipe în modal */
.list-group-item {
    padding: 12px 16px;
    font-size: 15px;
    border-radius: 8px;
    margin-bottom: 6px;
}

/* User search input */
#userSearchInput {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px !important; /* Previne zoom pe iOS */
    border-radius: 8px;
    border: 1.5px solid #e3e6ea;
    margin-bottom: 12px;
}

#userSearchInput:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.15);
}

@media (min-width: 768px) {
    .navbar {
        padding: 12px 20px;
    }

    .navbar-brand {
        font-size: 20px;
    }

    .navbar-nav .nav-link {
        padding: 8px 16px;
        font-size: 14px;
    }

    .dropdown-menu {
        min-width: 200px;
    }

    .dropdown-item {
        font-size: 14px;
        padding: 8px 16px;
    }

    button, a, .clickable {
        min-height: auto;
        min-width: auto;
    }
}

@media (min-width: 992px) {
    .navbar {
        padding: 12px 24px;
    }
}

/* ========================================
   ADVANCED MOBILE FEATURES
   ======================================== */

/* Touch states */
.touch-active {
    opacity: 0.7 !important;
    transform: scale(0.97) !important;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

.fast-tapped {
    animation: fastTap 0.2s ease;
}

@keyframes fastTap {
    50% { transform: scale(0.95); }
}

/* Pull to refresh indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: white;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 9999;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
}

.pull-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.pull-to-refresh-indicator.ready {
    background: #28a745;
    color: white;
}

.pull-to-refresh-indicator.ready .pull-spinner {
    border-color: rgba(255,255,255,0.3);
    border-top-color: white;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile toast notifications */
.mobile-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 99999;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90vw;
    text-align: center;
}

.toast-success { background: #28a745; color: white; }
.toast-error { background: #dc3545; color: white; }
.toast-info { background: #17a2b8; color: white; }
.toast-warning { background: #ffc107; color: #212529; }

/* iOS safe area support */
@supports (padding: max(0px)) {
    body {
        --sat: env(safe-area-inset-top, 0px);
        --sab: env(safe-area-inset-bottom, 0px);
        --sal: env(safe-area-inset-left, 0px);
        --sar: env(safe-area-inset-right, 0px);
    }
    
    .container {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    
    body.has-notch .navbar {
        padding-top: max(8px, env(safe-area-inset-top));
    }
    
    body.has-notch .export-menu {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Keyboard open state */
body.keyboard-open .status-bar,
body.keyboard-open .client-status-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Scroll states */
body.scroll-down .navbar {
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

body.scroll-up .navbar {
    transform: translateY(0);
    transition: transform 0.3s ease;
}

body.scrolled .navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Connection-aware loading */
body.connection-slow img,
body.connection-2g img {
    background: #f8f9fa;
}

body.save-data img {
    filter: grayscale(20%);
}

/* Battery-aware animations */
body.battery-low .programare-card,
body.battery-low .status-icon,
body.battery-low .toggle-option {
    transition-duration: 0.1s !important;
}

body.reduce-motion * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
}

/* Tablet-specific optimizations */
body.is-tablet #cardContainer {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 768px) {
    body.is-tablet #cardContainer {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Standalone PWA mode */
body.is-standalone .navbar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

body.is-standalone {
    padding-top: env(safe-area-inset-top, 0px);
}

/* Safari-specific fixes */
body.is-safari input,
body.is-safari textarea,
body.is-safari select {
    -webkit-appearance: none;
    appearance: none;
}

/* Landscape optimizations for phones */
@media (max-height: 500px) and (orientation: landscape) {
    .navbar {
        padding: 6px 12px;
    }
    
    #mapService {
        height: 200px;
    }
    
    .client-status-bar {
        padding: 8px;
    }
    
    .status-icon {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .modal-dialog {
        margin: 5px;
        max-height: 95vh;
        overflow-y: auto;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .programare-card,
    .status-icon,
    .export-btn {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Accessibility - prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support (opțional) */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4dabf7;
        --success-color: #51cf66;
        --danger-color: #ff6b6b;
        --warning-color: #ffd43b;
        --info-color: #22b8cf;
        --gray-light: #212529;
        --gray-medium: #343a40;
        --gray-dark: #adb5bd;
    }
    
    body {
        background: #1a1a1a;
        color: #e9ecef;
    }
    
    .programare-card,
    .client-status-bar,
    .export-menu,
    .modal-content {
        background: #2d2d2d;
        color: #e9ecef;
        border-color: #404040;
    }
    
    input, textarea, select {
        background: #343a40;
        color: #e9ecef;
        border-color: #495057;
    }
    
    #mapService {
        filter: brightness(0.8) contrast(1.2);
    }
}

/* ========================================
   STATISTICI PROGRAMĂRI
   ======================================== */
#statisticiProgramare {
    margin: 12px 0;
    background: var(--card-background-color, #fff);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

.statistici-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    transition: var(--transition);
}

.statistici-header:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

.statistici-header h3 {
    margin: 0;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.statistici-header h3 .material-icons {
    font-size: 1.25rem;
}

.statistici-header::after {
    content: 'expand_more';
    font-family: 'Material Icons';
    font-size: 1.5rem;
    color: #fff;
    transition: transform 0.3s ease;
}

.statistici-content.show + .statistici-header::after,
.statistici-header:has(+ .statistici-content.show)::after {
    transform: rotate(180deg);
}

.statistici-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.statistici-content.show {
    padding: 16px;
    max-height: 500px;
}

.statistici-content.hide {
    padding: 0;
    max-height: 0;
}

.statistici-list {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.statistici-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    color: #212529;
}

.statistici-list li:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.statistici-list li .material-icons {
    font-size: 1.25rem;
    color: #667eea;
}

.statistici-list li strong {
    font-weight: 600;
    color: #212529;
}

.statistici-content .btn {
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius);
}

.statistici-content .btn:last-child {
    margin-bottom: 0;
}

/* Mobile responsive pentru statistici */
@media (max-width: 480px) {
    .statistici-list {
        grid-template-columns: 1fr;
    }
    
    .statistici-header h3 {
        font-size: 0.9rem;
    }
    
    .statistici-list li {
        padding: 10px;
        font-size: 0.85rem;
    }
}

/* Spațiu pentru mobile bottom nav */
@media (max-width: 991.98px) {
    .client-status-bar {
        margin-bottom: 70px;
    }
}

