/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    overflow: hidden;
}

/* Шапка */
#header {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: white;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    position: relative;
}

h1 {
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

h2 {
    margin-bottom: 15px;
    color: #2e7d32;
    font-size: 18px;
}

/* Статус подключения */
.status {
    display: flex;
    gap: 20px;
    align-items: center;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.indicator.online {
    background: #4caf50;
}

.indicator.offline {
    background: #f44336;
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

/* Контейнер карты */
#map-container {
    display: flex;
    height: calc(100vh - 70px);
}

#map {
    flex: 1;
    height: 100%;
    background: #e5e3df;
}

/* Боковая панель */
#sidebar {
    width: 100%;
    max-width: 25rem;
    background: white;
    box-shadow: -2px 0 15px rgba(0,0,0,0.15);
    overflow-y: auto;
    padding: 20px;
}

#sidebar::-webkit-scrollbar {
    width: 8px;
}

#sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Секция управления */
.control-section {
    margin-bottom: 15px;
}

.control-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

/* Карточки информации */
.info-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 4px solid #2e7d32;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.info-card h3 {
    margin-bottom: 12px;
    color: #2e7d32;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.info-row:last-child {
    border-bottom: none;
}

.label {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.value {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    text-align: right;
}

/* Кнопки управления */
.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

button {
    background: linear-gradient(135deg, #2e7d32 0%, #388e3c 100%);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    white-space: nowrap;
}

button:hover {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

button:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: linear-gradient(135deg, #e8f5e9, #a5d6a7);
  border-color: #2e7d32;
  color: #1b5e20;
}

#load-tractors, #load-field-groups {
    width: 100%;
    margin-top: 10px;
    font-size: 13px;
    padding: 10px;
}

/* Выпадающие списки и инпуты */
select, input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: #2e7d32;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #2e7d32;
}

/* Уведомления */
#alert-container {
    position: fixed;
    top: 80px;
    right: 400px;
    z-index: 2000;
    max-width: 400px;
}

.alert {
    background: white;
    border-left: 4px solid #ffc107;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
}

.alert.success {
    border-left-color: #4caf50;
    background: #e8f5e9;
}

.alert.error {
    border-left-color: #f44336;
    background: #ffebee;
}

.alert.info {
    border-left-color: #2196f3;
    background: #e3f2fd;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Кастомная иконка трактора */
.tractor-icon {
    font-size: 32px;
    line-height: 1;
    text-align: center;
    transition: transform 0.5s ease;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

/* Адаптивность */
@media (max-width: 1024px) {
    #sidebar {
        width: 320px;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    #alert-container {
        right: 340px;
    }
}

@media (max-width: 768px) {
    #map-container {
        flex-direction: column;
    }

    #map {
        height: 50vh;
    }

    #sidebar {
        width: 100%;
        height: 50vh;
        box-shadow: 0 -2px 15px rgba(0,0,0,0.15);
    }

    #alert-container {
        right: 20px;
        left: 20px;
        max-width: none;
    }

    .status {
        flex-wrap: wrap;
        gap: 10px;
    }

    h1 {
        font-size: 18px;
    }
}

/* Popup карты */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    margin: 12px;
    font-size: 14px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    h1 span:last-child {
        font-size: 16px;
    }

    .status {
        gap: 5px;
    }

    .status-item {
        display: none;
    }

    /* Показать только индикатор */
    .indicator {
        display: block !important;
        width: 12px;
        height: 12px;
    }
}

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto; /* прижимает блок к правому краю */
}

#logout-btn {
    margin-left: 0; /* убрали инлайн margin-left: 10px, gap уже задаёт отступ */
}

@media (max-width: 480px) {
    #header h1 {
        display: none;
    }
}

 .lang-switcher {
        border-radius: 4px;
        border: 1px solid #ccc;
        font-size: 14px;
        cursor: pointer;
        background: #fff;
    }

    /* 🆕 Стили переключателя источника данных */
  /*  .api-mode-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border-radius: 6px;
        border: 1px solid #ccc;
        background: #fff;
        cursor: pointer;
        font-size: 13px;
        font-weight: 600;
        transition: all 0.25s ease;
        user-select: none;
    } */
  /*  .api-mode-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    } */
    /* Режим "Мій сервер" (backup) */
  /*  .api-mode-btn.mode-backup {
        background: linear-gradient(135deg, #e3f2fd, #bbdefb);
        border-color: #1976d2;
        color: #0d47a1;
    } */
    /* Режим "Cropwise Online" */
  /*  .api-mode-btn.mode-cropwise {
        background: linear-gradient(135deg, #e8f5e9, #a5d6a7);
        border-color: #2e7d32;
        color: #1b5e20;
    } */
   /* .api-mode-icon {
        font-size: 16px;
    } */

    /* Мобильная версия — только иконка */
    @media (max-width: 600px) {
        .api-mode-label { display: none; }
        .api-mode-btn { padding: 12px 16px; }
    }

    @keyframes agri-spin {
    to { transform: rotate(360deg); }
}

.storage-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(3px);
}

.storage-modal {
    width: min(420px, 100%);
    padding: 26px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 15px 45px rgba(0, 0, 0, .25);
    text-align: center;
    animation: storage-modal-show .2s ease-out;
}

.storage-modal-icon {
    font-size: 38px;
    margin-bottom: 8px;
}

.storage-modal h3 {
    margin: 0 0 12px;
    color: #263238;
    font-size: 20px;
}

.storage-modal p {
    margin: 8px 0;
    color: #455a64;
    line-height: 1.45;
    font-size: 14px;
}

.storage-modal-note {
    color: #78909c !important;
    font-size: 12px !important;
}

.storage-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 22px;
}

.storage-btn {
    min-width: 120px;
    padding: 9px 16px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: .2s ease;
}

.storage-btn:disabled {
    opacity: .6;
    cursor: wait;
}

.storage-btn-primary {
    color: #fff;
    background: #1976d2;
}

.storage-btn-primary:hover {
    background: #125ca1;
}

.storage-btn-secondary {
    color: #37474f;
    background: #eceff1;
}

.storage-btn-secondary:hover {
    background: #cfd8dc;
}

.storage-modal-closing {
    opacity: 0;
    transition: opacity .2s ease;
}

@keyframes storage-modal-show {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/*#storage-settings-button:disabled {
    opacity: .65;
    cursor: not-allowed;
    background: linear-gradient(135deg, #e8f5e9, #a5d6a7);
  border-color: #2e7d32;
  color: #1b5e20;
} */

#storage-settings-button.storage-enabled {
    opacity: .65;
    cursor: not-allowed;
}

.dq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 8px;
}

.dq-table th {
    background: #f5f5f5;
    padding: 7px 9px;
    text-align: left;
    border-bottom: 2px solid #ddd;
    font-size: 11px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.dq-table td {
    padding: 6px 9px;
    border-bottom: 1px solid #eee;
}

.dq-table th.num,
.dq-table td.num {
    text-align: right;
    white-space: nowrap;
}

.dq-table tbody tr:nth-child(even) { background: #fafbfc; }
.dq-table tbody tr:hover           { background: #f3f8fc; }