/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Шапка */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-tabs {
    display: flex;
    gap: 10px;
}

.tab {
    padding: 10px 20px;
    text-decoration: none;
    color: white;
    background-color: #34495e;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.tab:hover {
    background-color: #455a64;
}

.tab.active {
    background-color: #3498db;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logout-link {
    color: white;
    text-decoration: none;
}

.logout-link:hover {
    text-decoration: underline;
}

/* Основной контент */
.main-content {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: #2980b9;
}

.btn-primary {
    background-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger {
    background-color: #e74c3c;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Формы */
.form-section {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    flex: 1;
    margin-bottom: 15px;
}

.form-group-wide {
    flex: 1 1 100%;
    min-width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* Блоки изделий */
.item-block {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
}

.item-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.item-block-title {
    font-weight: bold;
    font-size: 14px;
    color: #2c3e50;
}

.btn-remove-item {
    padding: 4px 10px;
    font-size: 12px;
}

.item-images {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ddd;
}

.item-images > label {
    display: block;
    font-weight: bold;
    color: #555;
    margin-bottom: 5px;
}

.item-images .gallery {
    margin-top: 10px;
}

/* Таблицы */
.data-table {
    width: 100%;
    background: white;
    border-collapse: collapse;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.data-table th {
    background-color: #34495e;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: bold;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #ddd;
}

.data-table tr:hover {
    background-color: #f9f9f9;
}

.data-table tr.overdue {
    background-color: #ffebee;
}

.data-table tr.overdue:hover {
    background-color: #ffcdd2;
}

/* Ссылки на заказы в таблицах */
.order-link {
    color: #3498db;
    text-decoration: none;
    cursor: pointer;
}

.order-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Фильтры */
.filter-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.filter-tab {
    padding: 8px 16px;
    text-decoration: none;
    color: #333;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s;
}

.filter-tab:hover {
    background-color: #f5f5f5;
}

.filter-tab.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

/* Заголовок страницы */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1, h2 {
    color: #2c3e50;
    margin-bottom: 15px;
}

/* Авторизация */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #ecf0f1;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
}

/* Галерея */
.gallery {
    margin-top: 20px;
}

.gallery-main {
    text-align: center;
    margin-bottom: 15px;
}

.gallery-main img {
    max-width: 100%;
    max-height: 500px;
    border: 2px solid #ddd;
    border-radius: 4px;
}

.gallery-thumbs {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.gallery-thumbs .thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.gallery-thumbs .thumb:hover {
    border-color: #3498db;
}

.gallery-thumbs .thumb.active {
    border-color: #3498db;
    border-width: 3px;
}

/* Автодополнение */
.suggestions {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.suggestion-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.suggestion-item:hover {
    background-color: #f5f5f5;
}

.form-group {
    position: relative;
}

/* Блоки изделий */
.item-block {
    background: #f9f9f9;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Администрирование */
.admin-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.admin-block {
    background: white;
    padding: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.admin-block h2 {
    margin-bottom: 10px;
}

.admin-block p {
    margin-bottom: 15px;
    color: #666;
}

/* Печать */
.print-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: white;
}

.print-section {
    margin-bottom: 30px;
    page-break-inside: avoid;
}

.print-section h2 {
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.print-item {
    margin-bottom: 20px;
    padding: 10px;
    background: #f9f9f9;
}

.print-item-title {
    font-size: 16px;
    margin: 0 0 10px 0;
    color: #2c3e50;
}

.print-image {
    max-width: 100%;
    margin: 10px 0;
}

@media print {
    .header, .form-actions, .btn {
        display: none;
    }
    
    .print-container {
        box-shadow: none;
    }
}

/* Инлайн формы */
.inline-form {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.inline-form input[type="text"] {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.inline-form label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

/* Модальное окно */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.modal-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
    text-decoration: none;
}

/* Список платежей */
.payments-list {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.payments-list h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.payments-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.payments-table th,
.payments-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.payments-table th {
    background-color: #f5f5f5;
    font-weight: bold;
}

/* Календарь монтажей — на всю ширину, плитка */
.installation-calendar-wrap {
    width: 100%;
    max-width: 100%;
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.calendar-month-block {
    width: 100%;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
}

.calendar-month-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #2c3e50;
    padding-bottom: 12px;
    border-bottom: 2px solid #3498db;
}

.installation-calendar {
    width: 100%;
    border-collapse: separate;
    border-spacing: 10px;
    table-layout: fixed;
}

.installation-calendar thead th {
    width: 12.5%;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.installation-calendar thead th.calendar-week-total-header {
    font-size: 11px;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: 0;
}

.installation-calendar tbody td {
    width: 12.5%;
    vertical-align: top;
    padding: 0;
    border: none;
    min-height: 120px;
}

.installation-calendar .calendar-day {
    min-height: 120px;
    padding: 12px;
    border-radius: 10px;
    background: #fafafa;
    border: 1px solid #eee;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease;
}

.installation-calendar .calendar-day:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.installation-calendar .calendar-day-empty {
    background: #f5f5f5;
    border-color: #eee;
    box-shadow: none;
    min-height: 120px;
}

.installation-calendar .calendar-day-past,
.installation-calendar .calendar-day-weekend {
    background: #ececec;
    color: #888;
    border-color: #e0e0e0;
}

.installation-calendar .calendar-day-past.calendar-day-weekend {
    background: #e0e0e0;
    color: #777;
}

.installation-calendar .calendar-day-today {
    background: linear-gradient(135deg, #e8f4fc 0%, #d6ebf9 100%);
    border: 2px solid #3498db;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
}

.installation-calendar .calendar-day-today .calendar-day-num {
    color: #2980b9;
}

.calendar-day-num {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
    color: #2c3e50;
    line-height: 1.2;
}

.calendar-day-orders {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.calendar-order-link {
    display: block;
    font-size: 12px;
    line-height: 1.35;
    color: #2980b9;
    text-decoration: none;
    padding: 4px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.7);
    transition: background 0.2s ease, color 0.2s ease;
}

.calendar-order-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-order-amount {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: #5d6d7e;
    white-space: nowrap;
}

.calendar-order-link:hover {
    background: rgba(52, 152, 219, 0.15);
    color: #1a5276;
    text-decoration: none;
}

.calendar-order-link:hover .calendar-order-amount {
    color: #1a5276;
}

.calendar-week-total {
    min-height: 120px;
    padding: 12px;
    border-radius: 10px;
    background: #f0f7fc;
    border: 1px solid #d6e9f8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    vertical-align: top;
    text-align: center;
}

.calendar-week-total-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.calendar-week-total-amount {
    font-size: 13px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.3;
    word-break: break-word;
}

.installation-calendar tfoot td.calendar-month-total {
    padding: 16px 12px 4px;
    border: none;
    text-align: right;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.calendar-month-total-amount {
    font-size: 15px;
    font-weight: 700;
    color: #2980b9;
}
