/* =========================================
   ЭЛЕКТРОННАЯ КАССОВАЯ КНИГА - СТИЛИ
   Версия 6.2 - Улучшенная кроссбраузерность
   ========================================= */

/* Основные стили с вендорными префиксами */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

body {
    background: #0f0f0f;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, Arial, sans-serif;
    margin: 0;
    padding: 0;
}

/* Уведомления */
.cb-notification {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
    -webkit-animation: slideDown 0.3s ease;
    -moz-animation: slideDown 0.3s ease;
    -o-animation: slideDown 0.3s ease;
    animation: slideDown 0.3s ease;
}

.cb-notification.success {
    background: #4CAF50;
    color: white;
    border-left: 4px solid #2e7d32;
}

.cb-notification.warning {
    background: #ff9800;
    color: white;
    border-left: 4px solid #f57c00;
}

@-webkit-keyframes slideDown {
    from {
        opacity: 0;
        -webkit-transform: translateY(-20px);
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        -webkit-transform: translateY(-20px);
        -moz-transform: translateY(-20px);
        -ms-transform: translateY(-20px);
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
        -moz-transform: translateY(0);
        -ms-transform: translateY(0);
        transform: translateY(0);
    }
}

.cb-container {
    max-width: 1400px;
    margin: 40px auto;
    background: #1a1a1a;
    padding: 30px;
    border-radius: 8px;
    -webkit-box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    -moz-box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cb-container h1 {
    text-align: center;
    color: #4CAF50;
    margin-bottom: 30px;
    font-size: 28px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0;
    margin-bottom: 30px;
}

/* Сводка */
.cb-summary {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 15px 1fr 15px 1fr 15px 1fr;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: #252525;
    border-radius: 8px;
}

.cb-summary > div {
    padding: 15px;
    background: #2a2a2a;
    border-radius: 5px;
    border-left: 4px solid #4CAF50;
}

.cb-summary strong {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
    font-size: 12px;
    text-transform: uppercase;
}

.cb-summary .amount {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.cb-summary .income {
    color: #4CAF50;
}

.cb-summary .expense {
    color: #f44336;
}

.cb-summary .total {
    color: #2196F3;
}

/* Форма добавления */
.cb-form {
    background: #252525;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 30px;
}

/* Блок текущего времени в форме */
.cb-current-time-form {
    text-align: center;
    background: #2a2a2a;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 2px solid #2196F3;
    font-size: 16px;
}

.cb-current-time-form strong {
    color: #2196F3;
    margin-right: 10px;
    font-size: 14px;
}

.cb-current-time-form #current-time {
    color: #fff;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    font-size: 20px;
    letter-spacing: 1px;
}

.form-row {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 15px 1fr 15px 1fr 15px 1fr;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    color: #aaa;
    font-size: 14px;
    font-weight: 500;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 10px 12px;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-field select {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23fff" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 6"><polygon points="0,0 10,0 5,6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
    padding-right: 30px;
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: #4CAF50;
}

.form-field-wide {
    -ms-grid-column: 1;
    -ms-grid-column-span: 7;
    grid-column: 1 / -1;
}

/* Кнопки */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
    -o-transition: all 0.3s ease;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

button:hover {
    -webkit-transform: translateY(-1px);
    -moz-transform: translateY(-1px);
    -ms-transform: translateY(-1px);
    transform: translateY(-1px);
    -webkit-box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    -moz-box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-save {
    background: #4CAF50;
    color: white;
}

.btn-save:hover {
    background: #45a049;
}

.btn-add {
    background: #4CAF50;
    color: white;
    width: 100%;
    padding: 12px;
    font-size: 16px;
}

.btn-add:hover {
    background: #45a049;
}

.btn-cancel {
    background: #ff9800;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-cancel:hover {
    background: #f57c00;
}

/* Таблица - обычная версия */
.cb-table {
    width: 100%;
    border-collapse: collapse;
    background: #252525;
    border-radius: 8px;
    overflow: hidden;
}

.cb-table thead {
    background: #333;
}

.cb-table th {
    padding: 15px;
    text-align: left;
    color: #4CAF50;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.cb-table tbody tr {
    border-bottom: 1px solid #333;
    -webkit-transition: background 0.2s ease;
    -moz-transition: background 0.2s ease;
    -o-transition: background 0.2s ease;
    transition: background 0.2s ease;
}

.cb-table tbody tr:hover:not(.cancelled-row) {
    background: #2a2a2a;
}

.cb-table td {
    padding: 15px;
    color: #ddd;
}

.amount-cell {
    font-weight: 600;
    text-align: right;
}

.amount-cell.income {
    color: #4CAF50;
}

.amount-cell.expense {
    color: #f44336;
}

.action-cell {
    text-align: center;
    white-space: nowrap;
}

/* Аннулированные записи */
.cancelled-row {
    background: #1f1f1f !important;
    opacity: 0.6;
    filter: alpha(opacity=60); /* IE8 */
}

.cancelled-row td {
    text-decoration: line-through;
    color: #666 !important;
}

.cancelled-label {
    color: #ff9800;
    font-size: 11px;
    font-style: italic;
}

/* Форма входа */
.cb-login {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: #1a1a1a;
    border-radius: 8px;
    -webkit-box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    -moz-box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cb-login h2 {
    text-align: center;
    color: #4CAF50;
    margin-top: 0;
}

.cb-login label {
    display: block;
    margin-top: 15px;
    margin-bottom: 5px;
    color: #aaa;
    font-size: 14px;
}

.cb-login input {
    width: 100%;
    padding: 12px;
    background: #333;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
}

.cb-login input:focus {
    outline: none;
    border-color: #4CAF50;
}

.cb-login button {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    background: #4CAF50;
    color: white;
    font-size: 16px;
}

.cb-login button:hover {
    background: #45a049;
}

/* ===============================================
   АДАПТИВНОСТЬ ДЛЯ ПЛАНШЕТОВ И ТЕЛЕФОНОВ
   =============================================== */

/* Планшеты (768px - 1024px) */
@media (max-width: 1024px) {
    .cb-container {
        padding: 20px;
        margin: 30px 15px;
    }
    
    .cb-container h1 {
        font-size: 24px;
        letter-spacing: 1px;
    }
    
    .cb-summary {
        -ms-grid-columns: 1fr 12px 1fr;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 15px;
    }
    
    .cb-summary .amount {
        font-size: 20px;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .cb-container {
        padding: 15px;
        margin: 10px 5px;
        border-radius: 6px;
    }
    
    .cb-container h1 {
        font-size: 20px;
        margin-bottom: 20px;
        letter-spacing: 1px;
    }
    
    /* Блок времени в форме на мобильных */
    .cb-current-time-form {
        font-size: 14px;
        padding: 12px 15px;
        margin-bottom: 15px;
    }
    
    .cb-current-time-form strong {
        display: block;
        margin-bottom: 5px;
        margin-right: 0;
        font-size: 13px;
    }
    
    .cb-current-time-form #current-time {
        font-size: 18px;
    }
    
    /* Сводка - по одной колонке */
    .cb-summary {
        -ms-grid-columns: 1fr;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }
    
    .cb-summary > div {
        padding: 12px;
    }
    
    .cb-summary strong {
        font-size: 11px;
    }
    
    .cb-summary .amount {
        font-size: 20px;
    }
    
    /* Форма добавления */
    .cb-form {
        padding: 15px;
    }
    
    .form-row {
        -ms-grid-columns: 1fr;
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 15px;
    }
    
    .form-field label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .form-field input,
    .form-field select {
        padding: 10px;
        font-size: 14px;
    }
    
    .btn-add {
        padding: 14px;
        font-size: 15px;
    }
    
    /* МОБИЛЬНАЯ ТАБЛИЦА - КАРТОЧНЫЙ СТИЛЬ */
    .cb-table {
        display: block;
        overflow-x: visible;
    }
    
    .cb-table thead {
        display: none; /* Скрываем заголовки на мобильных */
    }
    
    .cb-table tbody {
        display: block;
    }
    
    .cb-table tbody tr {
        display: block;
        margin-bottom: 15px;
        padding: 15px;
        border: 1px solid #333;
        border-radius: 8px;
        background: #252525;
    }
    
    .cb-table tbody tr:hover {
        background: #2a2a2a;
    }
    
    .cb-table td {
        display: block;
        padding: 8px 0;
        text-align: left !important;
        border: none;
    }
    
    /* Добавляем метки перед каждым полем */
    .cb-table td:before {
        content: attr(data-label);
        display: inline-block;
        font-weight: 600;
        color: #4CAF50;
        width: 140px;
        font-size: 12px;
        text-transform: uppercase;
    }
    
    .amount-cell {
        text-align: left !important;
    }
    
    .action-cell {
        text-align: left !important;
        margin-top: 10px;
    }
    
    .btn-cancel {
        width: 100%;
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .cancelled-label {
        display: block;
        font-size: 12px;
    }
    
    /* Аннулированные записи на мобильных */
    .cancelled-row {
        border-color: #444;
    }
}

/* Очень маленькие экраны (до 480px) */
@media (max-width: 480px) {
    .cb-container {
        padding: 12px;
        margin: 5px;
    }
    
    .cb-container h1 {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .cb-current-time-form {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .cb-current-time-form strong {
        font-size: 12px;
    }
    
    .cb-current-time-form #current-time {
        font-size: 16px;
    }
    
    .cb-summary > div {
        padding: 10px;
    }
    
    .cb-summary strong {
        font-size: 10px;
    }
    
    .cb-summary .amount {
        font-size: 18px;
    }
    
    .cb-form {
        padding: 12px;
    }
    
    .cb-table tbody tr {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .cb-table td {
        padding: 6px 0;
        font-size: 13px;
    }
    
    .cb-table td:before {
        width: 100px;
        font-size: 11px;
    }
    
    .cb-notification {
        padding: 12px 15px;
        font-size: 13px;
    }
}

/* Оптимизация для очень широких экранов */
@media (min-width: 1400px) {
    .cb-summary {
        -ms-grid-columns: 1fr 15px 1fr 15px 1fr 15px 1fr;
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Дополнительные исправления для IE и старых браузеров */
.cb-table {
    *zoom: 1; /* IE6-7 */
}

.cb-table:before,
.cb-table:after {
    content: " ";
    display: table;
}

.cb-table:after {
    clear: both;
}

/* Фикс для input[type="number"] в Firefox */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Улучшенная поддержка для datetime-local */
input[type="datetime-local"] {
    position: relative;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    cursor: pointer;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
}
