/* Профессиональный стиль для системы учета инвентаря */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body[data-ui-theme="dark"] {
    --bg-color: #0b1220;
    --card-bg: #111827;
    --text-primary: #e5e7eb;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.45);
    --shadow-md: 0 10px 20px -10px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 20px 30px -15px rgba(0, 0, 0, 0.65);
}

/* ======= UI Select (custom searchable dropdown) ======= */
.ui-select-native {
    /* Keep in DOM for FormData/validation, but hide visually */
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.ui-select {
    width: 100%;
}

.ui-select-btn {
    width: 100%;
    height: 46px;
    padding: 12px 44px 12px 16px;
    font-size: 15px;
    line-height: 1.2;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ui-select-btn-content {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
    height: 30px; /* stable inner height so content doesn't jump */
}

.ui-select-placeholder {
    display: inline-flex;
    align-items: center;
    height: 30px;
    font-size: 15px;
    line-height: 30px;
}

/* Inline input is kept for typing, but visually hidden (so it doesn't look like a second field) */
.ui-select-btn .ui-select-inline-input {
    position: absolute !important;
    left: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.ui-select-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-width: 0;
    height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.10);
    border: 1px solid rgba(37, 99, 235, 0.18);
    color: #1e40af;
    font-weight: 600;
    font-size: 15px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ui-select-typeahead {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
    padding: 2px 0;
}

.ui-select-typeahead::before {
    content: "Поиск: ";
    font-weight: 700;
    color: rgba(100, 116, 139, 0.9);
}

.ui-select-clear {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.10);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
}
.ui-select-clear:hover {
    border-color: rgba(0,0,0,0.16);
    background: #f8fafc;
    color: var(--text-primary);
}
.ui-select-clear:active {
    transform: translateY(-50%) scale(0.98);
}
.ui-select-btn:hover {
    border-color: rgba(0,0,0,0.18);
    box-shadow: var(--shadow-sm);
}
.ui-select-btn:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.ui-select-btn[aria-disabled="true"] {
    opacity: 0.7;
    cursor: not-allowed;
    background: #f8fafc;
}
.ui-select-btn[aria-invalid="true"] {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.ui-select-btn .ui-select-placeholder {
    color: var(--text-secondary);
    opacity: 0.85;
}

.ui-select-caret {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #7f8c8d;
    pointer-events: none;
}

.ui-select-popover {
    position: fixed;
    z-index: 12050; /* above modal (10000) */
    background: white;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0,0,0,0.18);
    overflow: hidden;
    min-width: 240px;
}

.ui-select-popover-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.ui-select-search {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
}
.ui-select-search:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.ui-select-popover-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-secondary);
}
.ui-select-popover-close:hover {
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
}

.ui-select-options {
    max-height: 320px;
    overflow: auto;
    padding: 6px;
    background: white;
    -webkit-overflow-scrolling: touch;
}
.ui-select-option {
    width: 100%;
    border: 1px solid transparent;
    background: white;
    cursor: pointer;
    text-align: left;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 15px;
    color: var(--text-primary);
    transition: all 0.12s ease;
}
.ui-select-option:hover {
    background: #f8fafc;
    border-color: rgba(37, 99, 235, 0.20);
}
.ui-select-option[aria-selected="true"] {
    background: rgba(37, 99, 235, 0.08);
    border-color: rgba(37, 99, 235, 0.25);
}
.ui-select-option.ui-active {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.35);
}

.ui-select-mark {
    background: rgba(245, 158, 11, 0.22);
    color: inherit;
    padding: 0 2px;
    border-radius: 4px;
}

.ui-select-empty {
    padding: 14px 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

body[data-ui-theme="dark"] .ui-select-btn {
    background: #0f172a;
    border-color: #334155;
    color: #e5e7eb;
}

body[data-ui-theme="dark"] .ui-select-btn:hover {
    border-color: #475569;
}

body[data-ui-theme="dark"] .ui-select-caret {
    color: #94a3b8;
}

body[data-ui-theme="dark"] .ui-select-clear {
    background: #111827;
    border-color: #334155;
    color: #cbd5e1;
}

body[data-ui-theme="dark"] .ui-select-clear:hover {
    background: #1e293b;
    border-color: #475569;
    color: #e2e8f0;
}

body[data-ui-theme="dark"] .ui-select-popover {
    background: #111827;
    border-color: #334155;
    box-shadow: 0 14px 40px rgba(0,0,0,0.45);
}

body[data-ui-theme="dark"] .ui-select-popover-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

body[data-ui-theme="dark"] .ui-select-search {
    background: #0f172a;
    border-color: #334155;
    color: #e5e7eb;
}

body[data-ui-theme="dark"] .ui-select-search::placeholder {
    color: #94a3b8;
}

body[data-ui-theme="dark"] .ui-select-popover-close {
    color: #cbd5e1;
}

body[data-ui-theme="dark"] .ui-select-popover-close:hover {
    background: #1e293b;
    color: #f8fafc;
}

body[data-ui-theme="dark"] .ui-select-options {
    background: #111827;
}

body[data-ui-theme="dark"] .ui-select-option {
    background: #111827;
    color: #e5e7eb;
}

body[data-ui-theme="dark"] .ui-select-option:hover {
    background: #1e293b;
    border-color: rgba(96, 165, 250, 0.45);
}

body[data-ui-theme="dark"] .ui-select-option[aria-selected="true"] {
    background: rgba(59, 130, 246, 0.22);
    border-color: rgba(96, 165, 250, 0.55);
}

body[data-ui-theme="dark"] .ui-select-option.ui-active {
    background: rgba(59, 130, 246, 0.30);
    border-color: rgba(147, 197, 253, 0.70);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-color);
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Меню - профессиональные карточки */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.menu-button {
    display: flex;
    align-items: center;
    padding: 24px;
    background: var(--card-bg);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: pointer;
}

.menu-button:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.menu-button.big-button {
    min-height: 140px;
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
    border: none;
}

.menu-button.big-button:hover {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    box-shadow: var(--shadow-lg);
}

.menu-button.medium-button {
    min-height: 100px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.menu-button.medium-button:hover {
    background: #f8fafc;
    border-color: var(--primary-color);
}

.button-icon {
    font-size: 36px;
    margin-right: 16px;
    opacity: 0.9;
}

.big-button .button-icon {
    font-size: 42px;
}

.button-text h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.button-text h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.button-text p {
    font-size: 14px;
    opacity: 0.85;
    font-weight: 400;
}

/* Формы */
.form-container {
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Кнопки */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 4px;
    font-family: inherit;
    letter-spacing: 0.2px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
    width: 100%;
    margin: 20px 0;
}

/* Сканер */
.scanner-container {
    text-align: center;
    padding: 24px;
    background: #f8fafc;
    border-radius: 10px;
    margin: 24px 0;
    border: 1px solid var(--border-color);
}

.scanner-button {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    background: var(--warning-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin: 8px;
    transition: all 0.2s ease;
}

.scanner-button:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#scanner-video {
    width: 100%;
    max-width: 500px;
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid var(--border-color);
}

/* Таблицы */
.table-container {
    overflow-x: auto;
    margin: 24px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    background: var(--card-bg);
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    background: #f8fafc;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tr:hover {
    background: #f8fafc;
}

table tr:last-child td {
    border-bottom: none;
}

body[data-ui-theme="dark"] table {
    background: #111827 !important;
    color: #e5e7eb !important;
}

body[data-ui-theme="dark"] table th,
body[data-ui-theme="dark"] table td {
    border-bottom-color: #334155 !important;
    color: #e5e7eb !important;
}

body[data-ui-theme="dark"] table th {
    background: #0f172a !important;
    color: #cbd5e1 !important;
}

body[data-ui-theme="dark"] table tr:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}

/* Сообщения */
.alert {
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 8px;
    font-size: 15px;
    border-left: 4px solid;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: var(--success-color);
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: var(--danger-color);
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: var(--primary-color);
}

body[data-ui-theme="dark"] .alert-success {
    background: #123225;
    color: #b8f5d5;
}

body[data-ui-theme="dark"] .alert-error {
    background: #3a1d1f;
    color: #fecaca;
}

body[data-ui-theme="dark"] .alert-info {
    background: #172554;
    color: #bfdbfe;
}

/* Навигация */
.nav-buttons {
    display: flex;
    gap: 12px;
    margin: 24px 0;
}

.nav-buttons .btn {
    flex: 0 0 auto;
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 24px;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 28px;
    }
    
    .button-icon {
        font-size: 32px;
    }
    
    .big-button .button-icon {
        font-size: 36px;
    }
}

/* Печать */
@media print {
    .no-print {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .container {
        box-shadow: none;
        padding: 0;
    }
}

/* Дополнительные стили для упрощенной формы */
.big-action-button {
    width: 100%;
    padding: 32px;
    font-size: 20px;
    font-weight: 600;
    margin: 16px 0;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    font-family: inherit;
}

.big-action-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.big-action-button.secondary {
    background: var(--secondary-color);
}

.big-action-button.secondary:hover {
    background: #475569;
}

.auto-filled-info {
    background: #ecfdf5;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    display: none;
    border: 1px solid #a7f3d0;
}

.auto-filled-info.show {
    display: block;
}

.auto-filled-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #065f46;
}

.auto-filled-info p {
    margin: 8px 0;
    color: var(--text-primary);
}

.photo-preview {
    max-width: 300px;
    max-height: 300px;
    border-radius: 10px;
    margin: 20px 0;
    display: none;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.photo-preview.show {
    display: block;
}

.hidden-fields {
    display: none;
}

/* Улучшенные карточки для быстрого выбора */
#recentItems {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

#recentItems .btn {
    text-align: left;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

#recentItems .btn:hover {
    border-color: var(--primary-color);
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#recentItems .btn strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
}

#recentItems .btn small {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Поиск */
#itemSearch {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

#itemSearch:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#selectedItem {
    padding: 16px;
    background: #ecfdf5;
    border-radius: 8px;
    margin-top: 12px;
    border: 1px solid #a7f3d0;
}

#selectedItem strong {
    color: #065f46;
    font-weight: 600;
}
