/* ========== БАЗОВЫЕ СТИЛИ ========== */
* { box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    background: #f5f7fa; 
    margin: 0; 
    padding: 20px;
    line-height: 1.6;
    color: #1a1a1a;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 15px; }
a { text-decoration: none; color: #0a58ca; }
a:hover { color: #084298; }

/* ========== ЗАГОЛОВКИ ========== */
h1, h2 {
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; margin-top: 30px; }

/* ========== ФОРМА (КОНТЕЙНЕР) ========== */
.form-container {
    max-width: 600px;
    width: 100%;
}

/* ========== КНОПКИ ========== */
.btn {
    padding: 10px 20px;
    background: #0a58ca;
    color: white !important;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    white-space: nowrap;
    transition: 0.2s;
    text-align: center;
}
.btn:hover { background: #084298; opacity: 0.9; }
.btn-danger { background: #dc3545; }
.btn-secondary { background: #95a5a6; }
.btn-secondary:hover { background: #7f8c8d; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-outline {
    background: transparent !important;
    color: #7f8c8d !important;
    border: 1px solid #ddd;
}
.btn-outline:hover { background: #f5f5f5 !important; color: #1a1a1a !important; }

.btn-arrow {
    stroke: white;
    flex-shrink: 0;
}

/* ========== НАВИГАЦИЯ ========== */
.nav {
    background: white;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}
.nav .logo { font-size: 1.2em; font-weight: bold; color: #1a1a1a; }
.nav .nav-links { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    margin-left: auto;
}
.nav .nav-links a { color: #1a1a1a; font-weight: 500; }
.nav .nav-links a:hover { color: #0a58ca; }
.nav .actions { display: flex; align-items: center; gap: 10px; }

/* ===== ИКОНКИ В ШАПКЕ ===== */
.nav .actions .action-icon {
    padding: 4px;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-only { display: none !important; }

.upload-btn {
    background: #dc3545;
    color: white !important;
    border-radius: 6px;
    width: 36px;
    height: 36px;
}
.upload-btn:hover { background: #bb2d3b; transform: scale(1.05); }
.upload-btn svg { stroke: white; }

.profile-icon {
    color: #1a1a1a;
    font-size: 22px;
}
.profile-icon:hover { color: #0a58ca; transform: scale(1.05); }

.burger {
    display: none;
    cursor: pointer;
    padding: 5px;
    background: none;
    border: none;
    flex-direction: column;
    gap: 5px;
}
.burger span {
    display: block;
    width: 25px;
    height: 3px;
    background: #1a1a1a;
    transition: 0.3s;
    border-radius: 2px;
}

.mobile-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}
.desktop-btn { width: auto !important; }
.user-links {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-name { font-weight: 600; color: #1a1a1a; }
.logout-link { color: #dc3545; font-weight: 600; }

/* ========== ФИЛЬТР ========== */
.filter-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden;
}
.filter-toggle {
    padding: 14px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    user-select: none;
}
.filter-toggle:hover { background: #f1f3f5; }
.filter-arrow { transition: 0.3s; }
.filter-body {
    display: none;
    padding: 15px 20px 20px;
    border-top: 1px solid #eee;
    flex-direction: column;
    gap: 12px;
}
.filter-body.open { display: flex; }
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}
.filter-item {
    flex: 0 1 auto;
    min-width: 150px;
}
.date-row .filter-item {
    flex: 0 1 180px;
    min-width: 140px;
}
.actions-row {
    flex-wrap: nowrap;
}
.filter-actions {
    display: flex;
    gap: 10px;
    flex: 0 1 auto;
}
.filter-actions .btn { white-space: nowrap; }
.filter-actions .btn { flex: 0 1 auto; }

/* ========== ТАБЛИЦЫ ========== */
.table-wrap { overflow-x: auto; margin-bottom: 20px; }
table {
    border-collapse: collapse;
    width: 100%;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    min-width: 200px;
    border-radius: 8px;
}
th, td { border: 1px solid #eee; padding: 12px 14px; text-align: left; font-size: 14px; }
th { background: #f8f9fa; font-weight: 600; color: #555; }
tr:hover { background: #f8f9fa; }

/* ========== ФОРМЫ И ИНПУТЫ ========== */
input, select, textarea {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    background: #fff;
    transition: 0.2s;
    box-sizing: border-box; 
    min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #0a58ca; box-shadow: 0 0 0 3px rgba(52,152,219,0.1); }
.form-group { margin-bottom: 15px; }
.form-group label { font-weight: 600; display: block; margin-bottom: 6px; font-size: 14px; color: #555; }

.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    background: white;
    transition: 0.3s;
    color: #7f8c8d;
}
.drop-zone:hover { border-color: #0a58ca; background: #f8faff; }
.drop-zone .drop-icon { font-size: 32px; margin-bottom: 8px; }

.quick-dates {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.quick-dates .btn { padding: 6px 16px; font-size: 13px; flex: 0 1 auto; }

/* ========== ФУТЕР ========== */
footer {
    margin-top: 40px;
    padding: 20px 0;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    font-size: 14px;
    color: #7f8c8d;
}
footer a { color: #7f8c8d; margin: 0 10px; white-space: nowrap; }
footer a:hover { color: #0a58ca; }

/* ========== КАРТОЧКИ ДАШБОРДА ========== */
.dash-cards { display: flex; gap: 15px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    flex: 1;
    min-width: 200px;
    color: inherit !important;
    transition: 0.2s;
    display: block;
}
.dash-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.08); transform: translateY(-2px); }
.dash-card h3 { 
    margin: 0 0 10px; 
    font-size: 14px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: #0a58ca;
}
.dash-card .value { font-size: 28px; font-weight: bold; margin: 5px 0; color: #1a1a1a; }
.dash-card .doc-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 5px;
    font-size: 14px;
    color: #1a1a1a;
}

/* ========== АДАПТИВ: ПЛАНШЕТ И МОБИЛЬНЫЙ (≤768px) ========== */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container { overflow-x: hidden; }
    .form-container { max-width: 100%; }
    
    /* БУРГЕР-МЕНЮ */
    .burger { display: flex !important; }
    .nav .actions .btn-danger { display: none !important; }
    .nav {
        flex-wrap: wrap;
        justify-content: space-between;
        padding: 10px 15px;
        gap: 0;
    }
    .nav .logo {
        order: 2;
        text-align: center;
        margin: 0;
        flex: 1;
    }
    .burger { order: 1; margin-right: 0; }
    .nav .actions { order: 3; gap: 6px; }
    .mobile-only { display: flex !important; }
    
    .nav .nav-links {
        display: none !important;
        flex-direction: column;
        width: 100%;
        background: white;
        padding: 15px 20px 20px;
        order: 4;
        gap: 8px;
        border-top: 1px solid #eee;
        margin-top: 10px;
        border-radius: 0 0 8px 8px;
        box-shadow: none;
        margin-left: 0;
    }
    .nav .nav-links.show { display: flex !important; }
    .nav .nav-links a { 
        padding: 8px 0; 
        text-align: left; 
        font-size: 15px; 
        border-bottom: 1px solid #f5f5f5;
        width: 100%;
    }
    .nav .nav-links a:last-child { border-bottom: none; }

    .mobile-actions {
        margin-top: 10px;
        padding-top: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        align-items: center;
    }
    .mobile-actions .btn { 
        margin: 0 auto !important; 
        width: 100%; 
        max-width: 300px; 
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .desktop-btn { width: 100% !important; max-width: 300px; }
    
    .user-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 4px 0;
        width: 100%;
    }
    .user-name { font-weight: 600; color: #1a1a1a; }
    .logout-link { color: #dc3545; font-weight: 600; }

    /* ===== ФИЛЬТР (МОБИЛЬНЫЙ) ===== */
    .filter-row {
        flex-direction: column;
        gap: 12px;
    }
    .filter-item {
        width: 100%;
        flex: 1 1 100%;
        min-width: 0;
    }
    .date-row .filter-item {
        flex: 1 1 100%;
        min-width: 0;
    }
    .actions-row {
        flex-direction: column;
    }
    .filter-actions {
        width: 100%;
        gap: 10px;
    }
    .filter-actions .btn { flex: 1; }
    
    /* ===== ИНПУТЫ ДАТ (ФИКС: МИНИМАЛЬНЫЕ ПАДДИНГИ) ===== */
    input[type="date"] {
        max-width: 100%;
        min-width: 0;
        padding: 10px 4px; /* Минимальные отступы, чтобы влез текст даты */
        font-size: 14px;
        width: 100%;
        box-sizing: border-box;
    }

    /* ===== ТАБЛИЦЫ (КАРТОЧКИ) ===== */
    .table-wrap { overflow-x: hidden !important; max-width: 100vw; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr {
        margin-bottom: 15px;
        border-radius: 8px;
        padding: 15px;
        border: 1px solid #eee;
        width: 100%;
        box-sizing: border-box;
        background: transparent !important;
        box-shadow: none !important;
    }
    td:first-child { display: flex; padding: 4px 0; }
    td:first-child::before { content: ""; margin-right: 0; }
    td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0;
        border: none;
        border-bottom: 1px solid #f5f5f5;
        font-size: 14px;
        width: 100%;
    }
    td:last-child { border-bottom: none; }
    td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #7f8c8d;
        margin-right: 15px;
        flex-shrink: 0;
        font-size: 13px;
        padding-top: 2px;
    }

    /* ===== КОММЕНТАРИЙ (СВОРАЧИВАНИЕ) ===== */
    td.comment-cell {
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        flex-wrap: nowrap;
    }
    td.comment-cell .comment-text {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60%;
        transition: all 0.3s ease;
        color: #1a1a1a;
        word-break: break-all;
    }
    td.comment-cell.expanded .comment-text {
        white-space: normal;
        overflow: visible;
        max-width: 100%;
        text-overflow: clip;
    }

    /* ФОРМЫ */
    input, select, textarea { width: 100%; font-size: 15px; padding: 14px; }
    .btn { width: 100%; padding: 16px; margin: 8px 0; font-size: 16px; }
    .quick-dates .btn { width: auto; flex: 1; }
    
    /* ДАШБОРД */
    .dash-cards { flex-direction: column; }
    .dash-card { min-width: auto; }
    
    /* ФУТЕР */
    footer { display: flex; flex-direction: column; gap: 6px; }
    footer a { margin: 0; }
}

/* ========== ЧЕКБОКСЫ ========== */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    cursor: pointer;
}

    td[data-label="Превью"] img { max-width: 100%; height: auto; }
select[name="per_page"] { width: auto !important; min-width: 60px; max-width: 80px; }
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}
.pagination select { width: auto; min-width: 60px; }
@media (max-width: 768px) {
    .pagination { font-size: 13px; gap: 6px; }
}

@media (max-width: 768px) {
    iframe { width: 100% !important; height: 400px !important; }
}

.superadmin-nav .burger { display: flex !important; }
.superadmin-nav .nav-links { display: none !important; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: white; padding: 15px; z-index: 100; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.superadmin-nav .nav-links.show { display: flex !important; }

@media (max-width: 768px) {
    .doc-actions { flex-direction: column !important; gap: 8px !important; }
    .doc-actions .btn { width: 100%; text-align: center; }
}

.chat-panel { /* background: white; */ }
.chat-messages { background: white; border-radius: 4px; }

.chat-panel h3 { background: none; padding: 0; margin: 0 0 10px 0; }
.chat-messages { background: white; border: 1px solid #eee; padding: 10px; height: 200px; overflow-y: auto; border-radius: 4px; }

.doc-thumb { width: 50px; max-width: 50px; height: auto; border-radius: 4px; }
@media (max-width: 768px) {
    .doc-thumb { width: 100%; max-width: 100%; }
}
