/**
 * Felmérés Page Styles
 * Survey/Assessment Management UI Components
 * 
 * Following CSS structure:
 * 1. Tab enhancements
 * 2. Card components
 * 3. State components (loading, error, empty)
 * 4. Form improvements
 * 5. Group expanders
 * 6. Plan result cards
 * 7. Address fix styling
 * 8. Accessibility
 * 9. Responsive design
 */

/* ==========================================================================
   1. TAB ENHANCEMENTS
   ========================================================================== */

.felmeres-tabs .tabs-header {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--light-color);
    background: #f9f9f9;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.felmeres-tabs .tab-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    padding: 1rem 1.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    min-width: max-content;
    white-space: nowrap;
}

.felmeres-tabs .tab-btn i {
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.felmeres-tabs .tab-btn:hover {
    background: #f0f0f0;
    color: var(--dark-color);
}

.felmeres-tabs .tab-btn:hover i {
    opacity: 0.8;
}

.felmeres-tabs .tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #fff;
}

.felmeres-tabs .tab-btn.active i {
    opacity: 1;
    color: var(--primary-color);
}

/* Tab badge for counts */
.felmeres-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #ef4444;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 10px;
    margin-left: 0.25rem;
}

.felmeres-tab-badge.muted {
    background: #9ca3af;
}

/* ==========================================================================
   2. CARD COMPONENTS
   ========================================================================== */

.felmeres-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e8e8e8;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.felmeres-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

.felmeres-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
}

.felmeres-card-header-actions {
    display: flex;
    gap: 0.5rem;
}

.felmeres-card-compact {
    padding: 1rem;
    margin-bottom: 1rem;
}

.felmeres-map-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    white-space: nowrap;
}

.felmeres-map-action-btn {
    width: 2.35rem;
    min-width: 2.35rem;
    height: 2.35rem;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.felmeres-map-action-btn i {
    font-size: 0.95rem;
    line-height: 1;
}

/* Info card variant */
.felmeres-card-info {
    background: #f0f9ff;
    border-color: #bae6fd;
}

.felmeres-card-info .felmeres-card-header {
    border-bottom-color: #0ea5e9;
}

/* Warning card variant */
.felmeres-card-warning {
    background: #fffbeb;
    border-color: #fde68a;
}

.felmeres-card-warning .felmeres-card-header {
    border-bottom-color: #f59e0b;
}

/* ==========================================================================
   3. STATE COMPONENTS
   ========================================================================== */

/* Loading state */
.felmeres-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2.5rem;
    color: #6b7280;
    text-align: center;
}

.felmeres-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: felmeres-spin 0.8s linear infinite;
}

.felmeres-btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.felmeres-btn-inline-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: felmeres-spin 0.8s linear infinite;
    flex: 0 0 14px;
}

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

.felmeres-loading-text {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Progress indicator */
.felmeres-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.felmeres-progress-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.felmeres-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.felmeres-progress-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #0369a1;
    white-space: nowrap;
}

/* Error state */
.felmeres-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1.25rem;
    color: #991b1b;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.felmeres-error-icon {
    font-size: 1.25rem;
    color: #dc2626;
    flex-shrink: 0;
}

.felmeres-error-content {
    flex: 1;
}

.felmeres-error-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.felmeres-error-message {
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Empty state */
.felmeres-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #6b7280;
}

.felmeres-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
    color: #9ca3af;
}

.felmeres-empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.felmeres-empty-message {
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 400px;
    margin: 0 auto 1.5rem;
}

.felmeres-empty-action {
    margin-top: 1rem;
}

/* ==========================================================================
   4. FORM IMPROVEMENTS
   ========================================================================== */

.felmeres-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.felmeres-form-group {
    display: flex;
    flex-direction: column;
}

.felmeres-form-group.full-width {
    grid-column: 1 / -1;
}

.felmeres-form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    font-size: 0.9rem;
}

.felmeres-form-group .form-control {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.felmeres-form-group .form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(73, 171, 124, 0.15);
}

.felmeres-form-hint {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.35rem;
}

/* Constraint row - horizontal layout */
.felmeres-constraint-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.felmeres-constraint-row .felmeres-form-group {
    flex: 1;
    min-width: 140px;
}

/* Selected count badge */
.felmeres-selected-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #49ab7c 0%, #3d9168 100%);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.felmeres-selected-badge i {
    font-size: 1rem;
}

/* ==========================================================================
   5. GROUP EXPANDERS
   ========================================================================== */

.felmeres-group-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    overflow: hidden;
    transition: border-color 0.2s;
}

.felmeres-group-card:hover {
    border-color: #d1d5db;
}

.felmeres-group-card summary {
    padding: 1rem;
    background: #fafafa;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    list-style: none;
    user-select: none;
    transition: background 0.2s;
}

.felmeres-group-card summary::-webkit-details-marker {
    display: none;
}

.felmeres-group-card summary:hover {
    background: #f3f4f6;
}

.felmeres-group-card summary::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 5px solid #6b7280;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.felmeres-group-card[open] summary::before {
    transform: rotate(90deg);
}

.felmeres-group-card[open] summary {
    border-bottom: 1px solid #e5e7eb;
}

.felmeres-group-card-content {
    padding: 0;
}

.felmeres-group-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.felmeres-group-label {
    flex: 1;
    font-weight: 600;
    color: var(--dark-color);
}

.felmeres-group-count {
    font-size: 0.85rem;
    color: #6b7280;
    background: #e5e7eb;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
}

.felmeres-group-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 6px 0 12px;
    flex-wrap: wrap;
}

.felmeres-group-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--dark-color);
}

.felmeres-group-summary {
    margin-left: auto;
    font-size: 12px;
    color: #6b7280;
}

.felmeres-map-search-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 320px;
    max-width: 460px;
    flex: 1 1 360px;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.felmeres-map-search-wrap i {
    color: #64748b;
    font-size: 13px;
    flex-shrink: 0;
}

.felmeres-map-search-wrap:focus-within {
    border-color: #49ab7c;
    box-shadow: 0 0 0 3px rgba(73, 171, 124, 0.18);
    background: #ffffff;
}

.felmeres-map-search-input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: #0f172a;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
}

.felmeres-map-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.felmeres-route-point-picker {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    padding: 10px;
    margin: 0 0 8px;
}

.felmeres-route-point-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.felmeres-route-point-picker-title {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.felmeres-route-point-picker-subtitle,
.felmeres-route-point-picker-value {
    font-size: 12px;
    color: #4b5563;
    line-height: 1.4;
}

.felmeres-route-point-picker-value {
    white-space: nowrap;
    font-weight: 600;
}

.felmeres-route-point-picker-map {
    height: 320px;
    min-height: 320px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* ==========================================================================
   6. STATUS BADGES
   ========================================================================== */

.felmeres-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
}

.felmeres-status-loading {
    background: #dbeafe;
    color: #1e40af;
}

.felmeres-status-loading i {
    animation: felmeres-spin 1s linear infinite;
}

.felmeres-status-success {
    background: #dcfce7;
    color: #166534;
}

.felmeres-status-warning {
    background: #fef3c7;
    color: #92400e;
}

.felmeres-status-error {
    background: #fee2e2;
    color: #991b1b;
}

.felmeres-status-info {
    background: #e0f2fe;
    color: #0369a1;
}

/* ==========================================================================
   7. PLAN RESULT CARDS
   ========================================================================== */

.felmeres-plan-header {
    background: linear-gradient(135deg, #49ab7c 0%, #3d9168 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.felmeres-plan-header h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.felmeres-plan-header-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.felmeres-plan-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.felmeres-plan-stat {
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.felmeres-plan-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.felmeres-plan-stat-label {
    font-size: 0.8rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.felmeres-plan-overview {
    background: linear-gradient(180deg, #fcfefd 0%, #f6fbf8 100%);
    border: 1px solid #dce9e2;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.felmeres-plan-external-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
    margin-bottom: -8px;
}

.felmeres-plan-overview-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.felmeres-plan-title-group {
    min-width: 0;
}

.felmeres-plan-title {
    margin: 0;
    color: #1f2937;
    font-size: clamp(1.25rem, 2vw, 1.85rem);
    line-height: 1.2;
}

.felmeres-plan-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.felmeres-plan-actions-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.felmeres-plan-order-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.46rem 0.75rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.86rem;
    font-weight: 700;
    white-space: nowrap;
}

.felmeres-plan-order-badge-optimized {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.felmeres-plan-order-badge-manual {
    background: #fef3c7;
    color: #92400e;
    border-color: #f59e0b;
}

.felmeres-plan-order-badge-draft {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.felmeres-plan-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.felmeres-plan-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 10px;
    font-weight: 600;
}

.felmeres-plan-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 10px;
    font-weight: 600;
}

.felmeres-plan-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.7rem;
}

.felmeres-plan-kpi {
    background: #ffffff;
    border: 1px solid #e5ede8;
    border-radius: 12px;
    padding: 0.75rem 0.8rem;
    min-width: 0;
}

.felmeres-plan-kpi-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.4rem;
    color: #6b7280;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.felmeres-plan-kpi-label i {
    color: #2f9a6f;
    font-size: 0.88rem;
}

.felmeres-plan-kpi-value {
    color: #111827;
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.felmeres-route-inline-summary {
    color: #4b5563;
    font-size: 0.92rem;
    font-weight: 500;
}

.felmeres-plans-table-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
}

.felmeres-plans-table {
    width: max(100%, 1720px) !important;
    min-width: 1720px !important;
    max-width: none !important;
    table-layout: fixed;
}

.felmeres-plans-table th,
.felmeres-plans-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    word-break: normal;
    overflow-wrap: normal;
}

.app-md-shell.app-md-page-felmeres .main-content .felmeres-plans-table th,
.app-md-shell.app-md-page-felmeres .main-content .felmeres-plans-table td {
    padding: 0.58rem 0.55rem !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}

.felmeres-plans-table th {
    white-space: normal;
    hyphens: none;
}

.felmeres-plans-table td {
    white-space: nowrap;
}

.felmeres-plans-table td:first-child {
    white-space: normal;
}

.felmeres-plan-col-date {
    width: 17%;
}

.felmeres-plan-col-driver {
    width: 9%;
}

.felmeres-plan-col-stops {
    width: 6%;
}

.felmeres-plan-col-distance {
    width: 11%;
}

.felmeres-plan-col-duration {
    width: 11%;
}

.felmeres-plan-col-time {
    width: 7%;
}

.felmeres-plan-col-created {
    width: 12%;
}

.felmeres-plan-col-actions {
    width: 20%;
}

.felmeres-plan-row-actions-cell {
    overflow: visible !important;
    text-align: right;
    white-space: nowrap !important;
}

.felmeres-plan-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    min-width: max-content;
    white-space: nowrap;
}

.felmeres-plan-row-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    padding: 0 !important;
}

@media (max-width: 1100px) {
    .felmeres-plan-col-date {
        width: 21%;
    }

    .felmeres-plan-col-driver {
        width: 8%;
    }

    .felmeres-plan-col-stops {
        width: 5%;
    }

    .felmeres-plan-col-distance {
        width: 10%;
    }

    .felmeres-plan-col-duration {
        width: 12%;
    }

    .felmeres-plan-col-time {
        width: 7%;
    }

    .felmeres-plan-col-created {
        width: 12%;
    }

    .felmeres-plan-col-actions {
        width: 18%;
    }
}

/* Route section cards */
.app-md-module-crm.app-md-page-felmeres .main-content > .page-header {
    margin-left: 0.35rem !important;
    margin-right: 0.35rem !important;
}

.app-md-module-crm.app-md-page-felmeres .main-content .page-content {
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
}

.app-md-module-crm.app-md-page-felmeres .main-content .container {
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
}

.app-md-module-crm.app-md-page-felmeres .felmeres-tabs .tabs-content {
    padding-left: 0.65rem !important;
    padding-right: 0.65rem !important;
}

.felmeres-route-table-wrap {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0;
    margin-right: 0;
    padding: 0.35rem;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-wrap {
    overflow-x: auto !important;
    overflow-y: visible !important;
}

.app-md-shell.app-md-page-felmeres .main-content table.felmeres-route-table {
    table-layout: fixed !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table th,
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table td {
    padding: 0.48rem 0.4rem !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
    hyphens: none !important;
}

.felmeres-route-table th {
    white-space: normal;
}

.felmeres-route-table td {
    white-space: nowrap;
}

.felmeres-route-table:not(.felmeres-route-table-edit) td:nth-child(3),
.felmeres-route-table:not(.felmeres-route-table-edit) td:nth-child(5),
.felmeres-route-table-edit td:nth-child(4),
.felmeres-route-table-edit td:nth-child(6) {
    white-space: normal;
}

.felmeres-route-col-drag { width: 2rem; }
.felmeres-route-col-order { width: 2.25rem; }
.felmeres-route-col-project { width: 6.25rem; }
.felmeres-route-col-customer { width: 13.5rem; }
.felmeres-route-col-phone { width: 12rem; }
.felmeres-route-col-address { width: auto; }
.felmeres-route-col-travel { width: 7rem; }
.felmeres-route-col-km { width: 5.25rem; }
.felmeres-route-col-arrival { width: 5rem; }
.felmeres-route-col-stop { width: 5.5rem; }
.felmeres-route-col-departure { width: 5rem; }
.felmeres-route-col-actions { width: 3.25rem; }

.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit th:nth-child(1),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit td:nth-child(1),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit th:nth-child(2),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit td:nth-child(2),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit th:nth-child(12),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit td:nth-child(12) {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
    text-align: center !important;
}

.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit th:nth-child(5),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit td:nth-child(5) {
    white-space: nowrap !important;
}

.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit th:nth-child(6),
.app-md-shell.app-md-page-felmeres .main-content .felmeres-route-table-edit td:nth-child(6) {
    min-width: 0 !important;
}

.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-project {
    width: 8%;
}

.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-customer,
.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-phone {
    width: 12%;
}

.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-address {
    width: 21%;
}

.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-travel,
.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-arrival,
.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-stop {
    width: 9%;
}

.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-km,
.felmeres-route-table:not(.felmeres-route-table-edit) .felmeres-route-col-departure {
    width: 8%;
}

.felmeres-route-drag-cell {
    text-align: center;
}

.felmeres-route-actions-cell {
    overflow: visible !important;
    position: relative;
    text-align: center;
}

.felmeres-route-action-menu {
    position: relative;
    display: inline-block;
}

.felmeres-route-action-menu summary {
    list-style: none;
}

.felmeres-route-action-menu summary::-webkit-details-marker {
    display: none;
}

.felmeres-route-action-trigger {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    padding: 0 !important;
}

.felmeres-route-menu-panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 40;
    min-width: 13rem;
    padding: 0.35rem;
    background: #ffffff;
    border: 1px solid #d7e2ef;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.felmeres-route-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #172236;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.felmeres-route-menu-item:hover {
    background: #f1f7fb;
}

.felmeres-route-menu-item i {
    width: 1rem;
    color: #526277;
    text-align: center;
}

.felmeres-route-menu-item-danger {
    color: #b91c1c;
}

.felmeres-route-menu-item-danger i {
    color: #dc2626;
}

.felmeres-route-action-menu[open] .felmeres-route-action-trigger {
    background: #e8f5ee;
    border-color: #9de4bd;
    color: #16724f;
}

.felmeres-route-card {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    margin-bottom: 1rem;
    overflow: hidden;
}

.felmeres-route-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.felmeres-route-title {
    font-weight: 600;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.felmeres-route-title i {
    color: var(--primary-color);
}

.felmeres-route-summary {
    font-size: 0.9rem;
    color: #6b7280;
}

/* ==========================================================================
   8. ADDRESS FIX STYLING
   ========================================================================== */

.felmeres-fix-card {
    background: var(--white);
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.felmeres-fix-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.felmeres-fix-list {
    display: grid;
    gap: 1rem;
}

.felmeres-fix-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.felmeres-fix-project {
    font-weight: 600;
    color: var(--primary-color);
}

.felmeres-fix-customer {
    color: var(--dark-color);
    font-weight: 500;
}

.felmeres-fix-reason {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.felmeres-fix-reason-error {
    background: #fee2e2;
    color: #991b1b;
}

.felmeres-fix-reason-warning {
    background: #fef3c7;
    color: #92400e;
}

.felmeres-fix-reason-info {
    background: #dbeafe;
    color: #1e40af;
}

.felmeres-fix-address {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.felmeres-fix-current {
    color: #6b7280;
}

.felmeres-fix-suggestion {
    color: var(--primary-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.felmeres-fix-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f3f4f6;
}

/* Inline editor */
.felmeres-fix-editor {
    margin-top: 1rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.felmeres-fix-editor-input {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.felmeres-fix-editor-input input {
    flex: 1;
}

/* ==========================================================================
   9. AUTOCOMPLETE DROPDOWN
   ========================================================================== */

.felmeres-autocomplete {
    position: relative;
}

.felmeres-autocomplete-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-height: 280px;
    overflow-y: auto;
}

.felmeres-autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
    color: var(--dark-color);
    transition: background 0.15s;
}

.felmeres-autocomplete-item:last-child {
    border-bottom: none;
}

.felmeres-autocomplete-item:hover {
    background: #f0fdf4;
}

.felmeres-manual-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fcfa 100%);
    border-color: #dceee4;
}

.felmeres-manual-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.felmeres-manual-header h3 {
    margin: 0;
}

.felmeres-manual-subtitle {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: #5f6b66;
}

.felmeres-manual-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.felmeres-manual-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: #e8f6ef;
    color: #0f5132;
    font-size: 0.8rem;
    font-weight: 700;
}

.felmeres-manual-list {
    display: grid;
    gap: 12px;
}

.felmeres-manual-stop-row {
    border: 1px solid #dbe8e1;
    border-radius: 12px;
    background: #ffffff;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

.felmeres-manual-stop-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.felmeres-manual-stop-index {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1f2937;
    background: #f3f8f5;
    border: 1px solid #dceee4;
    border-radius: 999px;
    padding: 4px 10px;
}

.felmeres-manual-stop-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.felmeres-manual-stop-supplier-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #d7e5dd;
    border-radius: 999px;
    background: #f7fcf9;
    color: #334155;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.felmeres-manual-stop-supplier-toggle-label input {
    margin: 0;
}

.felmeres-manual-stop-grid {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(320px, 3fr) minmax(140px, 1fr);
    gap: 10px;
    align-items: end;
}

.felmeres-manual-stop-row.felmeres-manual-stop-no-supplier .felmeres-manual-stop-grid {
    grid-template-columns: minmax(320px, 5fr) minmax(140px, 1fr);
}

.felmeres-manual-stop-grid .felmeres-form-group {
    margin-bottom: 0;
}

.felmeres-manual-duration {
    min-width: 120px;
}

.felmeres-manual-empty {
    border: 1px dashed #b7d6c5;
    border-radius: 12px;
    padding: 18px;
    background: #f7fcf9;
    text-align: center;
}

.felmeres-manual-empty-title {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 4px;
}

.felmeres-manual-empty-text {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.felmeres-quick-start-options {
    display: grid;
    gap: 10px;
}

.felmeres-quick-start-option {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

.felmeres-edit-start-settings {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #d9e5de;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fcfa 100%);
}

.felmeres-edit-start-settings-grid {
    display: grid;
    grid-template-columns: minmax(320px, 560px) 220px;
    gap: 10px;
    justify-content: start;
    width: fit-content;
    max-width: 100%;
}

.felmeres-edit-manual-stop {
    margin-top: 10px;
    padding: 12px;
    border: 1px solid #d9e5de;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fcfa 100%);
}

.felmeres-edit-manual-stop-grid {
    display: grid;
    grid-template-columns: minmax(320px, 560px) 220px;
    gap: 10px;
    justify-content: start;
    width: fit-content;
    max-width: 100%;
}

.felmeres-edit-manual-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.felmeres-edit-manual-field label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #4b5563;
}

.felmeres-arrival-wait-warning {
    margin-top: 3px;
    font-size: 11px;
    color: #9a3412;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #ffedd5;
    border: 1px solid #fdba74;
    border-radius: 999px;
    padding: 2px 8px;
}

.felmeres-edit-manual-input {
    width: 100%;
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid #cfd8d3;
    background: #ffffff;
    font-size: 15px;
    font-weight: 500;
    color: #111827;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.felmeres-edit-manual-input:focus {
    border-color: #49ab7c;
    box-shadow: 0 0 0 3px rgba(73, 171, 124, 0.18);
}

.felmeres-edit-manual-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.felmeres-edit-manual-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border-radius: 10px;
    min-height: 42px;
    padding: 0.55rem 1rem;
    font-weight: 700;
}

/* ==========================================================================
   10. ACCESSIBILITY
   ========================================================================== */

/* Focus visible states */
.felmeres-tabs .tab-btn:focus-visible,
.felmeres-card:focus-within,
.felmeres-group-card summary:focus-visible,
.felmeres-form-group .form-control:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .felmeres-loading-spinner,
    .felmeres-status-loading i {
        animation: none;
    }
    
    .felmeres-group-card summary::before {
        transition: none;
    }
    
    * {
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .felmeres-card,
    .felmeres-group-card {
        border-width: 2px;
    }
    
    .felmeres-status,
    .felmeres-fix-reason {
        border: 1px solid currentColor;
    }
}

/* ==========================================================================
   11. RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 768px) {
    .felmeres-tabs .tabs-header {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .felmeres-tabs .tab-btn {
        flex: 0 0 auto;
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
    
    .felmeres-tabs .tab-btn span {
        display: none;
    }
    
    .felmeres-tabs .tab-btn i {
        font-size: 1.1rem;
    }
    
    .felmeres-form-grid {
        grid-template-columns: 1fr;
    }
    
    .felmeres-constraint-row {
        flex-direction: column;
    }
    
    .felmeres-constraint-row .felmeres-form-group {
        width: 100%;
    }
    
    .felmeres-plan-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .felmeres-plan-overview-top {
        flex-direction: column;
        align-items: stretch;
    }

    .felmeres-plan-title-row {
        align-items: flex-start;
    }

    .felmeres-plan-actions-wrap {
        justify-content: flex-start;
    }

    .felmeres-plan-external-actions {
        justify-content: stretch;
        margin-bottom: 8px;
    }

    .felmeres-plan-external-actions .felmeres-plan-export-btn {
        width: 100%;
        justify-content: center;
    }

    .felmeres-plan-actions {
        width: 100%;
    }

    .felmeres-plan-action-btn,
    .felmeres-plan-export-btn {
        width: 100%;
        justify-content: center;
    }

    .felmeres-plan-kpis {
        grid-template-columns: 1fr;
    }
    
    .felmeres-fix-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .felmeres-fix-actions {
        flex-direction: column;
    }

    .felmeres-fix-actions .btn {
        width: 100%;
    }

    .felmeres-fix-editor-input {
        flex-direction: column;
        align-items: stretch;
    }

    .felmeres-fix-editor-input .btn {
        width: 100%;
    }

    .felmeres-edit-start-settings-grid,
    .felmeres-edit-manual-stop-grid {
        grid-template-columns: 1fr;
    }

    .felmeres-edit-manual-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .felmeres-manual-header {
        flex-direction: column;
        align-items: stretch;
    }

    .felmeres-manual-header-actions {
        justify-content: space-between;
    }

    .felmeres-manual-stop-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .felmeres-manual-stop-actions {
        width: 100%;
        flex-direction: column;
    }

    .felmeres-manual-stop-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .felmeres-manual-stop-supplier-toggle-label {
        width: 100%;
        justify-content: center;
    }

    .felmeres-manual-stop-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .felmeres-card {
        padding: 1rem;
        border-radius: 8px;
    }
    
    .felmeres-plan-header {
        padding: 1rem;
    }
    
    .felmeres-plan-stats {
        grid-template-columns: 1fr;
    }
}
