/* Общие стили */
* {
    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 30px;
    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: 380px;
    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);
}

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 {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#load-tractors {
    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;
    }
}