/* styles.css - полный обновленный код */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --primary: #2c5282;
    --primary-light: #4299e1;
    --secondary: #38a169;
    --danger: #e53e3e;
    --warning: #d69e2e;
    --light: #f7fafc;
    --gray: #a0aec0;
    --dark: #2d3748;
    --border: #e2e8f0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --radius: 10px;
}

body {
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    overflow: hidden;
}

/* Стили для экрана авторизации */
.auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    border-top: 4px solid var(--primary);
}

.remember-me {
    margin: 20px 0 25px 0;
    display: flex;
    align-items: center;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 15px;
    color: var(--dark);
    user-select: none;
    width: 100%;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-radius: 5px;
    margin-right: 12px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--primary);
    font-size: 24px;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--gray);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: var(--light);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* Основной экран */
.header {
    background: white;
    padding: 25px 30px;
    border-radius: var(--radius);
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border-left: 5px solid var(--primary);
}

.header h1 {
    color: var(--primary);
    font-size: 26px;
    margin-bottom: 20px;
}

.controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
}

select, input[type="date"] {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    min-width: 150px;
}

/* Кнопки */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--secondary);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #c05621;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.print-controls {
    display: flex;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}

/* ТАБЛИЦА */
.table-wrapper {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 280px);
    position: relative;
}

#vehiclesTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    border-spacing: 0;
}

/* Фиксированные заголовки */
#vehiclesTable thead {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

#vehiclesTable th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: white;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 2px solid var(--primary);
    vertical-align: middle;
}

/* Контейнер для тела таблицы с одной полосой прокрутки */
.table-container {
    flex: 1;
    overflow: auto;
    position: relative;
}

/* Ширины колонок - ОДИНАКОВЫЕ для заголовка и таблицы */
.col-number { width: 60px; min-width: 60px; }
.col-garage { width: 120px; min-width: 120px; }
.col-name { width: 150px; min-width: 150px; }
.col-type { width: 120px; min-width: 120px; }
.col-defect { width: 100px; min-width: 100px; }
.col-route { width: 180px; min-width: 180px; }
.col-cargo-in { width: 180px; min-width: 180px; }
.col-cargo-out { width: 180px; min-width: 180px; }
.col-notes { width: 180px; min-width: 180px; }
.col-actions { width: 80px; min-width: 80px; }

/* Убедитесь, что th и td имеют одинаковые стили ширины */
#vehiclesTable th.col-defect,
#vehiclesTable td.col-defect {
    width: 100px;
    min-width: 100px;
    max-width: 100px;
}

/* ЯЧЕЙКИ ТАБЛИЦЫ - ЦЕНТРИРОВАННЫЕ ПО ВЫСОТЕ */
#vehiclesTable td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    box-sizing: border-box;
    height: 70px;
    overflow: hidden;
    display: table-cell;
}

/* Номер строки - центрированный */
#vehiclesTable td.col-number {
    text-align: center;
    vertical-align: middle;
}

#vehiclesTable td.col-number strong {
    display: block;
    line-height: 1;
}

#vehiclesTable tbody tr:hover {
    background: rgba(66, 153, 225, 0.05);
}

/* Поля ввода в таблице */
.table-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    box-sizing: border-box;
    transition: all 0.3s ease;
    line-height: 1.4;
    vertical-align: middle;
}

.table-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.1);
}

.table-textarea, .cargo-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    resize: vertical;
    min-height: 60px;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.5;
    box-sizing: border-box;
    transition: all 0.3s ease;
    vertical-align: middle;
    padding-top: 10px;
    padding-bottom: 10px;
}

.table-textarea:focus, .cargo-textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(66, 153, 225, 0.1);
}

/* Ячейка с чекбоксом - центрированная */
.checkbox-cell {
    text-align: center;
    vertical-align: middle;
    display: table-cell;
    height: 100%;
    width: 100%;
    overflow: visible;
}

/* Обертка для чекбокса внутри ячейки */
.checkbox-cell-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.table-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin: 0;
    vertical-align: middle;
    display: block;
    margin: 0 auto;
}

/* Кнопка удаления */
.btn-delete {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    transition: all 0.3s ease;
    vertical-align: middle;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.btn-delete:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-delete:disabled:hover {
    background: transparent;
    color: var(--danger);
}

/* Футер таблицы с кнопкой добавления */
.table-footer {
    padding: 15px;
    border-top: 1px solid var(--border);
    background: white;
    flex-shrink: 0;
}

.add-row-btn {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.add-row-btn:hover {
    background: var(--primary-light);
}

.add-row-btn:active {
    transform: scale(0.98);
}

/* Новая строка */
.new-row {
    background: rgba(66, 153, 225, 0.03);
}

/* Сообщения */
.error {
    color: var(--danger);
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
    padding: 10px;
    background: rgba(229, 62, 62, 0.1);
    border-radius: 6px;
}

.hidden {
    display: none;
}

/* Информация о сессии */
.session-info {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    padding: 12px;
    background: rgba(66, 153, 225, 0.05);
    border-radius: 8px;
    font-size: 13px;
    color: var(--dark);
    flex-wrap: wrap;
}

/* Стили для вертикальной полосы прокрутки - ОДНА полоса */
.table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* СТИЛИ ДЛЯ ПЕЧАТИ */
@media print {
    @page {
        size: A4 landscape;
        margin: 0;
    }
    
    body {
        margin: 0 !important;
        padding: 15mm 10mm !important;
        background: white !important;
        font-size: 6pt !important;
        color: black !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
        box-sizing: border-box !important;
    }
    
    /* Скрываем все ненужное */
    .auth-screen,
    .header,
    .table-footer,
    .btn-delete,
    .table-checkbox,
    .checkbox-cell-wrapper {
        display: none !important;
    }
    
    /* Показываем основной экран */
    #mainScreen {
        display: block !important;
    }
    
    /* Заголовок печати */
    .print-header {
        display: block !important;
        text-align: center;
        margin: 0 0 8mm 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    .print-header h2 {
        font-size: 9pt !important;
        font-weight: bold !important;
        margin: 0 0 2mm 0 !important;
        color: black !important;
    }
    
    .print-info {
        font-size: 6.5pt !important;
        color: black !important;
        margin: 0 !important;
    }
    
    /* Таблица для печати */
    .table-wrapper {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
    }
    
    #vehiclesTable {
        width: 270mm !important;
        border-collapse: collapse !important;
        font-size: 6pt !important;
        table-layout: fixed !important;
        margin: 0 auto !important;
    }
    
    #vehiclesTable thead {
        position: static !important;
    }
    
    #vehiclesTable th {
        background: #e0e0e0 !important;
        color: black !important;
        padding: 1mm 0.5mm !important;
        border: 0.2mm solid black !important;
        vertical-align: middle !important;
    }
    
    #vehiclesTable td {
        padding: 0.8mm 0.5mm !important;
        font-size: 6pt !important;
        text-align: center !important;
        vertical-align: middle !important;
        border: 0.2mm solid black !important;
        height: auto !important;
    }
    
    /* Скрываем последний столбец */
    .col-actions, td:last-child {
        display: none !important;
    }
    
    /* Ширины для печати */
    .col-number { width: 8mm !important; }
    .col-garage { width: 15mm !important; }
    .col-name { width: 25mm !important; }
    .col-type { width: 20mm !important; }
    .col-defect { width: 12mm !important; }
    .col-route { width: 35mm !important; }
    .col-cargo-in { width: 35mm !important; }
    .col-cargo-out { width: 35mm !important; }
    .col-notes { width: 35mm !important; }
    
    /* Выравнивание текстовых полей */
    .col-route,
    .col-cargo-in,
    .col-cargo-out,
    .col-notes {
        text-align: left !important;
        vertical-align: top !important;
    }
    
    /* Поля ввода для печати */
    .table-input,
    .table-textarea,
    .cargo-textarea {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 6pt !important;
        font-family: inherit !important;
        color: black !important;
        resize: none !important;
        width: 100% !important;
        height: 100% !important;
        min-height: inherit !important;
        white-space: pre-wrap !important;
        vertical-align: middle !important;
    }
    
    /* Чекбоксы для печати */
    .checkbox-cell .checkbox-cell-wrapper,
    .checkbox-cell input {
        display: none !important;
    }
    
    .checkbox-cell::after {
        content: attr(data-print-status);
        display: block;
        width: 100%;
        text-align: center;
        font-size: 7pt !important;
        vertical-align: middle !important;
        font-weight: bold;
    }
    
    /* Скрываем пустые строки */
    .new-row {
        display: none !important;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .control-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    select, input[type="date"] {
        width: 100%;
    }
    
    .print-controls {
        margin-left: 0;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .login-card {
        padding: 30px 20px;
    }
    
    .table-wrapper {
        height: calc(100vh - 320px);
    }
    
    .btn-warning span {
        font-size: 12px;
    }
    
    /* Адаптивные ячейки на мобильных */
    #vehiclesTable td {
        padding: 8px;
        height: auto;
        min-height: 60px;
    }
    
    .table-textarea, .cargo-textarea {
        min-height: 40px;
        max-height: 80px;
    }
}