/* =====================================================
   Базовые стили и сброс
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Цветовая палитра */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --success-hover: #15803d;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    
    /* Нейтральные цвета */
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    /* Сообщения */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --info-bg: #dbeafe;
    --info-text: #1e40af;
    
    /* Размеры */
    --border-radius: 8px;
    --border-radius-sm: 6px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* =====================================================
   Контейнер и структура
   ===================================================== */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* =====================================================
   Форма ввода
   ===================================================== */
.form-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.input-row {
    display: flex;
    gap: 12px;
}

.input-field {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-field::placeholder {
    color: var(--text-muted);
}

/* =====================================================
   Кнопки
   ===================================================== */
.btn {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    box-shadow: var(--shadow-md);
}

.btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: white;
}

.btn-remove svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

/* =====================================================
   Сообщения
   ===================================================== */
.message-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.message-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-left: 4px solid var(--success-color);
}

.message-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-left: 4px solid var(--danger-color);
}

.message-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-left: 4px solid #f59e0b;
}

.message-info {
    background: var(--info-bg);
    color: var(--info-text);
    border-left: 4px solid var(--primary-color);
}

.message-icon {
    font-size: 18px;
    font-weight: 700;
}

.message-text {
    flex: 1;
}

/* =====================================================
   Секция со списком записей
   ===================================================== */
.records-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 12px;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: 700;
    border-radius: 16px;
}

/* =====================================================
   Список записей
   ===================================================== */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.record-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.record-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.record-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.record-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 100px;
    flex-shrink: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
}

.cover-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-default {
    object-fit: contain;
    opacity: 0.5;
}

.record-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.record-inventory {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-color);
}

.record-title {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.record-database {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
}

.quantity-info {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--info-bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.record-quantity {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
}

.quantity-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.quantity-input {
    width: 70px;
    padding: 8px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background: var(--surface-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
    outline: none;
}

.quantity-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.quantity-input::-webkit-inner-spin-button,
.quantity-input::-webkit-outer-spin-button {
    opacity: 1;
    height: 30px;
}

/* =====================================================
   Пустое состояние
   ===================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 14px !important;
    font-weight: 400 !important;
    color: var(--text-muted) !important;
    margin-bottom: 0 !important;
}

/* =====================================================
   Секция действий
   ===================================================== */
.actions-section {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* =====================================================
   Адаптивность
   ===================================================== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header h1 {
        font-size: 24px;
    }

    .input-row {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .actions-section {
        flex-direction: column-reverse;
    }

    .message-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    .record-item {
        flex-wrap: wrap;
    }

    .record-number {
        order: 1;
    }

    .record-cover {
        order: 2;
        width: 60px;
        height: 80px;
    }

    .record-content {
        order: 3;
        flex: 1;
        min-width: 0;
    }

    .record-quantity {
        order: 4;
        flex-direction: row;
        padding: 8px 0;
        width: 100%;
        justify-content: center;
    }

    .quantity-input {
        width: 60px;
    }

    .btn-remove {
        order: 5;
        margin-left: auto;
    }
}

@media (max-width: 480px) {
    .form-section,
    .records-section {
        padding: 16px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .count-badge {
        align-self: flex-start;
    }
}

/* =====================================================
   Печать
   ===================================================== */
@media print {
    .form-section,
    .actions-section,
    .message-container,
    .btn-remove {
        display: none;
    }

    body {
        background: white;
    }

    .container {
        max-width: 100%;
    }

    .records-section {
        border: none;
        box-shadow: none;
    }

    .record-item {
        page-break-inside: avoid;
    }
}