* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: Arial, sans-serif; background: #f5f5f5; color: #333; }

/* ===================== */
/* LAYOUT & SIDEBAR      */
/* ===================== */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #2c2c2c; padding: 20px 0; display: flex; flex-direction: column; flex-shrink: 0; z-index: 500; }
.sidebar-logo { color: #fff; font-size: 20px; font-weight: bold; padding: 0 20px 20px; border-bottom: 1px solid #444; }
.sidebar a { color: #ccc; text-decoration: none; padding: 12px 20px; display: block; }
.sidebar a:hover, .sidebar a.active { background: #444; color: #fff; }
.sidebar .logout-link { margin-top: auto; color: #e74c3c; }
.content { flex: 1; padding: 30px; overflow-x: auto; }
.public-layout { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* Sidebar toggle (mobile) */
.sidebar-toggle { display: none; position: fixed; top: 10px; left: 10px; z-index: 600; background: #2c2c2c; color: #fff; border: none; font-size: 22px; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; top: 0; height: 100%; transition: left 0.25s; }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); z-index: 499; }
    .sidebar-overlay.open { display: block; }
    .content { padding: 60px 15px 15px; }
}

/* ===================== */
/* LANDING               */
/* ===================== */
.landing { text-align: center; }
.landing h1 { font-size: 36px; margin-bottom: 10px; }
.landing p { font-size: 18px; color: #666; margin-bottom: 8px; }
.landing-buttons { margin-top: 30px; }

/* ===================== */
/* BUTTONS               */
/* ===================== */
.btn { display: inline-block; padding: 12px 30px; background: #722f37; color: #fff; text-decoration: none; border-radius: 5px; border: none; cursor: pointer; font-size: 16px; }
.btn:hover { background: #5a252c; }
.btn-outline { background: transparent; border: 2px solid #722f37; color: #722f37; }
.btn-outline:hover { background: #722f37; color: #fff; }

/* ===================== */
/* FORMS (login/register)*/
/* ===================== */
.form-container { width: 100%; max-width: 400px; }
.form-container h1 { margin-bottom: 20px; }
.form-container label { display: block; margin-top: 12px; font-weight: bold; font-size: 14px; }
.form-container input { width: 100%; padding: 10px; margin-top: 4px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.form-container button { margin-top: 20px; width: 100%; padding: 12px; background: #722f37; color: #fff; border: none; border-radius: 4px; font-size: 16px; cursor: pointer; }
.form-container button:hover { background: #5a252c; }
.form-container p { margin-top: 15px; font-size: 14px; }
.form-container a { color: #722f37; }
.error { background: #fdd; color: #c00; padding: 10px; border-radius: 4px; margin-bottom: 15px; }
.success { background: #dfd; color: #060; padding: 10px; border-radius: 4px; margin-bottom: 15px; }

/* ===================== */
/* PAGE HEADER           */
/* ===================== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-header h1 { margin: 0; }

/* ===================== */
/* FILTER CHIPS          */
/* ===================== */
.filters-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filter-chip { position: relative; height: 34px; display: flex; align-items: center; background: #fff; border: 1px solid #ccc; border-radius: 4px; padding: 0 8px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.filter-chip-search { padding: 0; border: none; background: none; }
.filter-chip-search input { height: 34px; padding: 0 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 12px; width: 240px; }
.filter-label { display: flex; align-items: center; gap: 3px; user-select: none; }
.filter-value { color: #722f37; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.filter-reset { background: none; border: none; color: #c00; font-size: 15px; cursor: pointer; margin-left: 4px; line-height: 1; padding: 0 2px; }
.filter-reset:hover { color: #a00; }
.filter-dropdown { display: none; position: absolute; top: 100%; left: 0; min-width: 180px; background: #fff; border: 1px solid #ccc; border-radius: 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 200; padding: 6px 0; margin-top: 2px; }
.filter-dropdown.open { display: block; }
.filter-dropdown .filter-search { width: calc(100% - 12px); margin: 0 6px 6px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 3px; font-size: 12px; }
.filter-options { max-height: 200px; overflow-y: auto; }
.filter-options label { display: flex; align-items: center; padding: 5px 10px; font-size: 12px; cursor: pointer; user-select: none; }
.filter-options label:hover { background: #f5f5f5; }
.filter-options input[type="checkbox"] { display: none; }
.filter-options label::before { content: ''; display: inline-block; width: 16px; margin-right: 8px; flex-shrink: 0; text-align: center; font-size: 13px; }
.filter-options label:has(input:checked) { background: #f0e8e9; }
.filter-options label:has(input:checked)::before { content: '✓'; color: #722f37; font-weight: bold; }
.filter-reset-all { width: 34px; height: 34px; background: #c00; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.filter-reset-all:hover { background: #a00; }

/* ===================== */
/* WINE TABLE            */
/* ===================== */
.wine-table { background: #fff; border-radius: 6px; border: 1px solid #ddd; overflow-x: auto; }
.wine-table-header { display: flex; padding: 8px 10px; background: #f0f0f0; font-weight: bold; font-size: 11px; color: #666; border-bottom: 1px solid #ddd; min-width: 1000px; }
.wine-row { display: flex; padding: 6px 10px; border-bottom: 1px solid #eee; align-items: center; font-size: 12px; min-width: 1000px; }
.wine-row:hover { background: #fafafa; }
.wine-row-empty { padding: 30px; text-align: center; color: #999; }

.col-photo { width: 40px; flex-shrink: 0; }
.col-photo img { width: 32px; height: 32px; object-fit: cover; border-radius: 3px; }
.no-photo { width: 32px; height: 32px; background: #f0f0f0; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.col-color { width: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.col-name { flex: 2; font-weight: 500; padding-right: 6px; overflow: hidden; text-overflow: ellipsis; }
.col-qty { width: 34px; flex-shrink: 0; text-align: center; }
.col-minorder { width: 34px; flex-shrink: 0; text-align: center; }
.col-pack { width: 50px; flex-shrink: 0; text-align: center; font-size: 11px; }
.col-country { width: 70px; flex-shrink: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.col-region { width: 80px; flex-shrink: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.col-subregion { width: 80px; flex-shrink: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.col-price { flex: 0.7; text-align: right; font-size: 11px; padding-right: 4px; }
.col-status { width: 22px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.col-actions { width: 62px; flex-shrink: 0; display: flex; gap: 4px; justify-content: flex-end; }
.price-up { color: #27ae60; }
.price-down { color: #e74c3c; }

.color-badge { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; border: 1px solid rgba(0,0,0,0.1); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-green { background: #27ae60; }
.status-red { background: #e74c3c; }
.status-blue { background: #2980b9; }

.btn-icon { width: 26px; height: 26px; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.btn-amend { background: transparent; border: 1px solid #f39c12; color: #f39c12; }
.btn-amend:hover { background: #f39c12; color: #fff; }
.btn-delete { background: #e74c3c; color: #fff; font-weight: bold; }
.btn-delete:hover { background: #c0392b; }

/* ===================== */
/* MODAL                 */
/* ===================== */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-content { background: #fff; border-radius: 8px; max-height: 90vh; overflow-y: auto; }
.modal-large { width: 92%; max-width: 780px; }
.modal-small { width: 90%; max-width: 400px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 36px; border-bottom: 1px solid #eee; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #999; }

.modal-body { padding: 24px 36px 28px; }

.modal-footer-btns { display: flex; justify-content: space-between; margin-top: 20px; gap: 12px; }
.btn-quit { padding: 10px 20px; background: #fff; border: 1px solid #999; color: #666; border-radius: 5px; cursor: pointer; font-size: 14px; }
.btn-quit:hover { background: #f5f5f5; }
.modal-footer-btns .btn { flex: 1; text-align: center; padding: 12px; }

.btn-cancel { padding: 10px 24px; background: #fff; border: 1px solid #999; color: #666; border-radius: 4px; cursor: pointer; font-size: 14px; }
.btn-cancel:hover { background: #f5f5f5; }
.btn-confirm-delete { padding: 10px 24px; background: #e74c3c; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; }
.btn-confirm-delete:hover { background: #c0392b; }

/* ===================== */
/* FORM GROUPS           */
/* ===================== */
.modal-body .form-group { margin-bottom: 12px; }
.modal-body .form-group label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 3px; color: #555; }
.modal-body .form-group input, .modal-body .form-group select { width: 100%; padding: 7px 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.modal-body .form-group input:disabled, .modal-body .form-group select:disabled { background: #eee; color: #999; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.form-row-3 { display: flex; gap: 10px; }
.form-row-3 .form-group { flex: 1; }
.form-row-4 { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.fg-pack { width: 110px; flex-shrink: 0; flex-grow: 0; }
.fg-qty { width: 36px; flex-shrink: 0; flex-grow: 0; }
.fg-minorder { width: 52px; flex-shrink: 0; flex-grow: 0; }
.fg-qty input, .fg-minorder input { padding: 7px 2px; text-align: center; -moz-appearance: textfield; }
.fg-restrict { flex: 1; min-width: 140px; }
.fg-minbuy { width: 150px; flex-shrink: 0; flex-grow: 0; }

/* Remove number spinners globally in modal */
.modal-body input[type="number"]::-webkit-inner-spin-button,
.modal-body input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.modal-body input[type="number"] { -moz-appearance: textfield; }

/* Vintage validation */
.vintage-invalid { border-color: #e74c3c !important; background: #fef0f0 !important; }

/* Vintage */
.vintage-group { display: flex; align-items: center; gap: 6px; }
.vintage-group input { width: 76px; }
.checkbox-label { display: flex; align-items: center; gap: 3px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* Price with currency */
.price-input { display: flex; gap: 0; }
.currency-select { width: 80px !important; flex-shrink: 0; border-radius: 4px 0 0 4px; border-right: none; font-size: 12px; padding: 7px 4px; text-align: center; }
.currency-display { width: 80px; flex-shrink: 0; border-radius: 4px 0 0 4px; border: 1px solid #ccc; border-right: none; background: #eee; color: #999; font-size: 12px; padding: 7px 4px; text-align: center; display: flex; align-items: center; justify-content: center; }
.price-input input { border-radius: 0 4px 4px 0; flex: 1; min-width: 0; }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-list { display: none; position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid #ccc; border-top: none; border-radius: 0 0 4px 4px; max-height: 150px; overflow-y: auto; z-index: 100; }
.autocomplete-item { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.autocomplete-item:hover { background: #f0f0f0; }

/* ===================== */
/* REGION PICKER         */
/* ===================== */
.region-picker { display: flex; gap: 6px; border: 1px solid #ccc; border-radius: 4px; padding: 8px; background: #fafafa; }
.region-col { flex: 1; min-width: 0; }
.region-col-disabled { opacity: 0.4; pointer-events: none; }
.region-col-header { display: flex; gap: 4px; margin-bottom: 4px; }
.region-col-header input { flex: 1; min-width: 0; padding: 4px 6px; border: 1px solid #ddd; border-radius: 3px; font-size: 11px; }
.btn-new-region { background: #722f37; color: #fff; border: none; border-radius: 3px; padding: 4px 6px; font-size: 10px; cursor: pointer; white-space: nowrap; }
.btn-new-region:hover { background: #5a252c; }
.btn-new-region:disabled { background: #ccc; cursor: default; }
.region-col-list { max-height: 140px; overflow-y: auto; border: 1px solid #eee; border-radius: 3px; background: #fff; }
.region-item { padding: 4px 7px; font-size: 11px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.region-item:hover { background: #f5f5f5; }
.region-item.selected { background: #722f37; color: #fff; }

/* ===================== */
/* PHOTO UPLOAD          */
/* ===================== */
.photo-upload-zone { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.photo-dropzone { width: 86px; height: 86px; border: 2px dashed #ccc; border-radius: 6px; display: flex; align-items: center; justify-content: center; cursor: pointer; text-align: center; font-size: 10px; color: #999; padding: 5px; }
.photo-dropzone.dragover { border-color: #722f37; background: #fef0f0; }
.photo-previews { display: flex; gap: 8px; }
.photo-preview { position: relative; width: 86px; height: 86px; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.photo-remove { position: absolute; top: -5px; right: -5px; width: 18px; height: 18px; background: #e74c3c; color: #fff; border: none; border-radius: 50%; cursor: pointer; font-size: 12px; line-height: 16px; text-align: center; }
.btn-take-photo { height: 86px; padding: 0 10px; background: #f5f5f5; border: 2px dashed #ccc; border-radius: 6px; cursor: pointer; font-size: 11px; color: #666; }
.btn-take-photo:hover { background: #eee; }

/* ===================== */
/* INFO TOOLTIP          */
/* ===================== */
.info-tooltip { position: relative; display: inline-block; cursor: help; font-size: 12px; color: #888; margin-left: 3px; font-weight: normal; }
.info-tooltip-text { display: none; position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 12px; border-radius: 6px; font-size: 11px; line-height: 1.5; width: 280px; z-index: 300; font-weight: normal; white-space: normal; }
.info-tooltip:hover .info-tooltip-text { display: block; }
.info-tooltip-text::after { content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: #333; }
