.stock-management-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.stock-header {
    text-align: center;
    margin-bottom: 30px;
}

.stock-header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.stock-subtitle {
    color: #7f8c8d;
    font-size: 1.1em;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card.warning { border-left: 4px solid #f39c12; }
.stat-card.danger { border-left: 4px solid #e74c3c; }
.stat-card.success { border-left: 4px solid #27ae60; }

.stat-icon {
    font-size: 2em;
}

.stat-content h3 {
    margin: 0;
    font-size: 1.8em;
    color: #2c3e50;
}

.stat-content p {
    margin: 5px 0 0 0;
    color: #7f8c8d;
    word-break:break-word;
}

.dashboard-stats .stat-card { min-height: 84px; }

.quick-actions {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    font-size: 0.97em;
}

.btn-primary { background: #3498db; color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-info { background: #17a2b8; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-danger { background: #dc3545; color: white; }

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.products-section {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.table-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
}

.table-controls input,
.table-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.table-container {
    overflow-x: auto;
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
    font-size: 0.97rem;
}

.stock-table th,
.stock-table td {
    padding: 7px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.stock-table th {
    background: #f8f9fa;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    font-size: 0.98em;
    padding-top: 6px;
    padding-bottom: 6px;
}

.stock-table th:hover {
    background: #e9ecef;
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 500;
}

.status-good { background: #d4edda; color: #155724; }
.status-low { background: #fff3cd; color: #856404; }
.status-out { background: #f8d7da; color: #721c24; }

.actions {
    display: flex;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: nowrap;
}

.btn-small {
    padding: 5px 7px;
    border: none;
    background: #f8f9fa;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.88em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.btn-small:hover {
    background: #e9ecef;
}

/* Modal overlay - hidden by default; JS shows it by setting style.display = 'flex' */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0; /* top:0; right:0; bottom:0; left:0; */
    background-color: rgba(0,0,0,0.5);
    /* Use flex layout when the modal is shown by JS (modal.style.display = 'flex') */
    align-items: center;
    justify-content: center;
    padding: 20px; /* ensures spacing on small screens */
    overflow: auto; /* allow overlay to scroll if necessary */
}

/* Modal box - constrained height and scrollable if content exceeds viewport */
.modal-content {
    background-color: white;
    padding: 14px 12px;
    border-radius: 8px;
    width: 100%;
    max-width: 520px;
    box-sizing: border-box;
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Close button */
.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Stock filters layout */
.stock-filters {
    --filter-bg: linear-gradient(135deg, #f8fbff 0%, #eef5fb 100%);
    --filter-border: #d8e3ea;
    --filter-shadow: 0 6px 16px rgba(33, 61, 90, 0.08);
    --filter-accent: #1f6f8b;
    background: var(--filter-bg);
    border: 1px solid var(--filter-border);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: var(--filter-shadow);
    animation: stockFiltersIn 0.35s ease-out;
    width: 100%;
}

.stock-filters__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stock-filters__search label,
.stock-filters .form-group label {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-size: 0.88rem;
    color: #1f2937;
    letter-spacing: 0.2px;
}

.stock-filters__search input[type="text"],
.stock-filters select {
    border: 1px solid #cfd9e3;
    border-radius: 8px;
    padding: 7px 10px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.stock-filters__search input[type="text"]:focus,
.stock-filters select:focus {
    border-color: var(--filter-accent);
    box-shadow: 0 0 0 2px rgba(31, 111, 139, 0.2);
    outline: none;
}

.stock-filters__search-results {
    max-height: 200px;
    overflow: auto;
    margin-top: 6px;
}

.stock-filters__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    align-items: end;
}

.stock-filters__reset {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.stock-filters__reset .btn {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    font-weight: 600;
    border-radius: 8px;
}

@keyframes stockFiltersIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
    .stock-filters {
        padding: 12px;
    }

    .stock-filters__grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .stock-filters__reset {
        justify-content: stretch;
    }

    .stock-filters__reset .btn {
        width: 100%;
    }
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.low-stock-alerts {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-left: 4px solid #f39c12;
}

.low-stock-alerts .table-container { width: 100%; overflow-x: auto; }
.low-stock-alerts .stock-table { width: 100%; border-collapse: collapse; }
.low-stock-alerts .stock-table th,
.low-stock-alerts .stock-table td { padding: 10px 12px; border-bottom: 1px solid #eee; }
.low-stock-alerts .stock-table tbody tr { background: #fff; }
.low-stock-alerts .stock-table tbody tr.alert-item { background: #fff8e1; }

.inventory-category {
    margin-bottom: 1em;
}
.inventory-category .category-toggle {
    width: 100%;
    text-align: left;
    font-weight: bold;
    margin-bottom: 0.2em;
    cursor: pointer;
}
.inventory-category .category-table-container {
    padding-left: 1em;
    border-left: 2px solid #3498db;
    margin-bottom: 0.5em;
}

.low-stock-alerts .product-name { font-weight: 600; color: #856404; }
.low-stock-alerts .stock-level { color: #856404; }
.low-stock-alerts .reorder-point { color: #6c757d; font-size: 0.9em; }

/* --- Kitchen-specific adjustments (responsive-friendly) --- */

/* Larger touch targets for kitchen modal buttons and mobile-friendly layout */
.kitchen-modal-actions {
    display:flex;
    gap:12px;
    margin-bottom:12px;
}
.kitchen-mode-btn {
    flex:1;
    padding:12px 14px;
    font-size:1.05rem;
    border-radius:8px;
    border:1px solid #ddd;
    cursor:pointer;
    background:#f7f7f7;
}
.kitchen-mode-btn.active {
    box-shadow:0 4px 12px rgba(0,0,0,0.12);
    transform:translateY(-1px);
}
.kitchen-mode-btn.set { background: #e9f6ff; border-color:#bfe9ff; }
.kitchen-mode-btn.waste { background: #fff5f5; border-color:#ffcfcf; }
.kitchen-reason-row { margin-top:8px; display:none; }
.kitchen-product-header { margin-bottom:10px; font-weight:600; font-size:1.1rem; }
.kitchen-product-sub { color:#666; font-size:0.95rem; margin-bottom:10px; }

/* Improve table readability on small screens: allow horizontal scroll and smaller padding */
@media (max-width: 1024px) {
    .stock-table th,
    .stock-table td {
        padding: 6px 6px;
        font-size: 0.93rem;
    }
    .btn, .btn-small {
        padding: 8px 10px;
    }
    .products-section {
        padding: 8px;
    }
    .modal-content {
        padding: 10px 6px;
        max-width: 440px;
    }
}

/* Tablet and mobile layout adjustments */
@media (max-width: 768px) {
    .dashboard-stats { grid-template-columns: 1fr 1fr; }
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }
    .table-controls {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }
    .table-controls input,
    .table-controls select {
        width: 100%;
    }
    .action-buttons {
        flex-direction: column;
    }
    .products-section {
        padding: 6px;
    }
    .stock-table th,
    .stock-table td {
        padding: 5px 4px;
        font-size: 0.92rem;
    }
    .btn-small {
        padding: 7px;
        width: 100%;
        text-align: center;
    }
    .kitchen-modal-actions { flex-direction: column; }
    .kitchen-mode-btn { font-size: 0.97rem; padding: 8px; }
    .inventory-category .category-table-container { padding-left: 0; border-left: none; }
    .low-stock-alerts .alert-list { padding-left: 0; border-left: none; }
    .modal-content { width: calc(100% - 24px); max-width: 340px; padding: 8px 4px; }
}

/* Small phones */
@media (max-width: 480px) {
    .dashboard-stats { grid-template-columns: 1fr; }
    .stat-content h3 { font-size: 1.2em; }
    .kitchen-mode-btn { padding: 8px; font-size: 0.95rem; }
    .stock-table th, .stock-table td { font-size: 0.88rem; padding: 4px 2px; }
    .form-actions { flex-direction: column-reverse; gap: 6px; }
    .form-actions .btn { width: 100%; }
    .modal-content { padding: 8px 2px; max-width: 98vw; }
}

/* Accessibility / touch improvements */
.kitchen-mode-btn,
.btn,
.btn-small {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Actions menu styling (dropdown-style) */
.actions-cell {
    position: relative;
    min-width: 56px;
    text-align: left;
    white-space: nowrap;
}

.actions-menu-toggle {
    background: transparent;
    border: 1px solid #e0e0e0;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.05rem;
}

.actions-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e6e6e6;
    box-shadow: 0 6px 14px rgba(0,0,0,0.08);
    border-radius: 6px;
    padding: 6px 0;
    list-style: none;
    margin: 0;
    min-width: 170px;
    z-index: 2000;
}

.actions-menu.open,
.actions-menu[aria-hidden="false"] {
    display: block;
}

.actions-menu li {
    margin: 0;
}

.actions-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
}

.actions-menu-item:hover,
.actions-menu-item:focus {
    background: #f5f7fb;
    outline: none;
}

/* ensure small screens display menu full width near cell */
@media (max-width: 480px) {
    .actions-menu {
        right: 8px;
        left: 8px;
        min-width: auto;
    }
}

/* Ensure table export / CSV uses sensible wrapping on small screens */
@media (max-width: 640px) {
    .stock-table td pre, .stock-table td code {
        white-space: pre-wrap;
        word-break: break-word;
    }
}

/* Keep table horizontally scrollable for very wide tables on mobile (fallback) */
.table-container {
    -webkit-overflow-scrolling: touch;
}

/* Product Group Styling */
.inventory-group {
    margin-bottom: 2em;
}

.group-header {
    background: #3498db;
    color: white;
    padding: 12px 16px;
    margin: 0 0 1em 0;
    border-radius: 6px;
    font-size: 1.2em;
}

.group-header-row td {
    background: #e8f4f8 !important;
    font-weight: bold;
    font-size: 1.1em;
    color: #2c3e50;
}

.category-subheader-row td {
    background: #f5f5f5 !important;
    font-style: italic;
    padding-left: 24px !important;
}

.product-group-section {
    margin-bottom: 2em;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.product-group-header {
    background: #3498db;
    color: white;
    padding: 12px 16px;
    margin: 0;
    font-size: 1.1em;
}

.product-group-section table {
    margin: 0;
}

/* Loading spinner styles */
.spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* End of file */