/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --gray: #6c757d;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f6fa;
    color: #333;
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--primary);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo,
.sidebar-header .sidebar-logo {
    max-width: 70px;
    height: 70px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 50%;
}

.sidebar-header h2 {
    font-size: 1.2em;
    margin-bottom: 5px;
}

.user-name {
    font-size: 0.9em;
    opacity: 0.8;
}

.user-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    margin-top: 8px;
}

.user-badge.admin {
    background: var(--danger);
}

.user-badge.user {
    background: var(--success);
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
    gap: 10px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    background: var(--secondary);
}

.nav-item.logout {
    margin-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    color: var(--danger);
}

.nav-icon {
    font-size: 1.2em;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 20px;
}

/* Content Header */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.content-header h1 {
    color: var(--primary);
    font-size: 1.8em;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Save Bar */
.save-bar {
    background: #d4edda;
    padding: 8px 15px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.save-bar span {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
}

/* Search Section */
.search-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary);
}

/* Categories */
.categories-section {
    margin-bottom: 20px;
}

.categories-tabs, .subcategories-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.category-tab, .subcategory-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
}

.category-tab:hover, .subcategory-tab:hover {
    border-color: var(--secondary);
    transform: translateY(-2px);
}

.category-tab.active, .subcategory-tab.active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}

.category-tab.active .btn-icon,
.subcategory-tab.active .btn-icon {
    color: white;
}

.category-color {
    width: 15px;
    height: 15px;
    border-radius: 50%;
}

.category-name, .subcategory-name {
    font-weight: 500;
}

/* Products Container */
.products-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--box-shadow);
    transition: all 0.3s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.product-card.changed {
    background: #fff3cd;
    border-left: 4px solid var(--warning);
}

.product-header {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.product-name {
    font-size: 1.2em;
    color: var(--primary);
}

.product-id {
    color: var(--gray);
    font-size: 0.85em;
}

.product-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
}

.product-badge.available {
    background: #d4edda;
    color: #155724;
}

.product-badge.unavailable {
    background: #f8d7da;
    color: #721c24;
}

.product-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 0.85em;
    color: var(--gray);
    flex-wrap: wrap;
}

.product-category {
    font-weight: 500;
}

/* Variants */
.product-variants {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.variants-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0;
}

.variant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

.variant-weight {
    font-weight: bold;
    min-width: 80px;
}

.variant-price-input {
    width: 100px;
    padding: 5px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.variant-status-select {
    padding: 5px;
    border-radius: 4px;
}

.variant-price {
    font-weight: bold;
    color: var(--success);
}

.variant-status {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8em;
}

.variant-status.available {
    background: #d4edda;
    color: #155724;
}

.variant-status.unavailable {
    background: #f8d7da;
    color: #721c24;
}

/* Product Controls */
.product-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
}

.product-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.product-status-select {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    border: 1px solid #e9ecef;
}

.change-indicator {
    color: var(--warning);
    font-size: 1.2em;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-warning {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary { background: var(--secondary); color: white; }
.btn-primary:hover { background: #2980b9; }

.btn-secondary { background: var(--gray); color: white; }
.btn-secondary:hover { background: #5a6268; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #219a52; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #d35400; }

.btn-small {
    padding: 4px 8px;
    font-size: 0.8em;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.3s;
}

.btn-icon:hover {
    background: rgba(0,0,0,0.1);
}

.btn-icon.danger:hover {
    background: #f8d7da;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    position: relative;
}

.modal-large {
    max-width: 800px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray);
}

.close:hover {
    color: var(--dark);
}

/* Forms */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--primary);
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--secondary);
}

/* Admin Panel */
.admin-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--gray);
    transition: all 0.3s;
}

.tab-btn:hover {
    color: var(--secondary);
}

.tab-btn.active {
    color: var(--secondary);
    border-bottom: 2px solid var(--secondary);
}

/* User List */
.users-list, .categories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.user-item, .category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    flex-wrap: wrap;
    gap: 10px;
}

.user-info, .category-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.user-role-badge {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8em;
}

.user-role-badge.admin {
    background: var(--danger);
    color: white;
}

.user-role-badge.user {
    background: var(--success);
    color: white;
}

.user-status {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8em;
}

.user-status.active {
    background: #d4edda;
    color: #155724;
}

.user-status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.user-actions, .category-actions {
    display: flex;
    gap: 5px;
}

/* Add Form */
.add-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 50px;
    color: var(--gray);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

/* Loading */
.loading-container {
    text-align: center;
    padding: 50px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--secondary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notifications */
.notification {
    padding: 12px 20px;
    margin-bottom: 15px;
    border-radius: var(--border-radius);
    font-weight: 500;
    display: block;
}

.notification-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.notification-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.notification-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Log Page */
.log-container {
    margin-top: 20px;
}

.log-date-group {
    margin-bottom: 25px;
}

.log-date-header {
    background: var(--primary);
    color: white;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.log-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.log-time {
    min-width: 80px;
    font-weight: bold;
    color: var(--secondary);
}

.log-content {
    flex: 1;
}

.log-header {
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.log-type {
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.8em;
}

.log-type-create {
    background: #d4edda;
    color: #155724;
}

.log-type-update {
    background: #fff3cd;
    color: #856404;
}

.log-type-delete {
    background: #f8d7da;
    color: #721c24;
}

.log-entity {
    color: var(--gray);
    font-size: 0.9em;
}

.log-change {
    margin: 8px 0;
    padding: 8px;
    background: white;
    border-radius: var(--border-radius);
}

.old-value {
    color: var(--danger);
    text-decoration: line-through;
}

.new-value {
    color: var(--success);
}

.arrow {
    margin: 0 10px;
}

.log-meta {
    font-size: 0.8em;
    color: var(--gray);
    margin-top: 8px;
}

/* Stats Cards */
.stats-cards {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--box-shadow);
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: var(--secondary);
}

.stat-label {
    color: var(--gray);
    font-size: 0.9em;
}

/* Import Page */
.import-section {
    background: white;
    padding: 25px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 20px;
}

.file-format-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    overflow-x: auto;
}

.format-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.format-table th, .format-table td {
    border: 1px solid #dee2e6;
    padding: 8px;
    text-align: left;
}

.format-table th {
    background: #e9ecef;
}

.note {
    margin-top: 10px;
    font-size: 0.9em;
    color: var(--warning);
}

.upload-form {
    margin-top: 20px;
}

.sample-download {
    text-align: center;
    padding: 20px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--gray);
    font-size: 0.8em;
    margin-top: 30px;
    border-top: 1px solid #e9ecef;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    
    .sidebar-header h2, .sidebar-header .user-name, .sidebar-header .user-badge {
        display: none;
    }
    
    .nav-item span:last-child {
        display: none;
    }
    
    .main-content {
        margin-left: 70px;
    }
    
    .product-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .variant-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}
/* ===== Toast Notifications (utils.js) ===== */
#globalNotification {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    padding: 14px 22px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    max-width: 360px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
#globalNotification.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
#globalNotification.notification-success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
#globalNotification.notification-error   { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
#globalNotification.notification-warning { background: #fff3cd; color: #856404; border-left: 4px solid #ffc107; }
#globalNotification.notification-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }

/* ===== Variant Read-Only Display (product card) ===== */
.variant-readonly {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
    margin-bottom: 5px;
}
.variant-weight-label {
    font-weight: 600;
    color: #2c3e50;
    min-width: 50px;
}
.variant-price-label {
    color: #555;
    font-size: 0.92em;
}
.variant-price-label strong {
    color: #27ae60;
    font-size: 1em;
}
.no-variants {
    color: #999;
    font-style: italic;
    font-size: 0.9em;
    padding: 4px 0;
}

/* ===== Variant Row in Edit Modal ===== */
.variant-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}
.variant-row select.variant-weight {
    flex: 0 0 110px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
    background: #fff;
}
.variant-price-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}
.variant-price-wrapper input.variant-price {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9em;
}
.price-euro-sign {
    font-weight: 600;
    color: #555;
    font-size: 0.95em;
}

/* old category row CSS removed */

/* ============================================================
   KATEGORIE-NAVIGATION — Neues professionelles Design
   ============================================================ */

/* Wrapper-Zeilen */
.categories-section { padding: 0 0 4px; }

.categories-row {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.categories-row::-webkit-scrollbar { display: none; }

/* ---- Zeilenbeschriftung ---- */
.cat-row-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 6px 12px 6px 0;
    margin-right: 10px;
    border-right: 2px solid currentColor;
    opacity: 0.7;
}
.cat-label-main { color: #2c3e50; }
.cat-label-sub  { color: #7f8c8d; }

.subcat-row { margin-top: 6px; padding-bottom: 2px; }

/* ============================================================
   HAUPTKATEGORIEN — Karten mit farbigem Icon
   ============================================================ */
.maincat-card {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px 7px 8px;
    margin: 0 5px 0 0;
    border-radius: 10px;
    border: 2px solid transparent;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: box-shadow 0.18s, border-color 0.18s, transform 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
}
.maincat-card:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.13);
    transform: translateY(-1px);
}
.maincat-card--active {
    border-color: var(--mcat-color, #3498db) !important;
    background: color-mix(in srgb, var(--mcat-color, #3498db) 8%, #fff);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--mcat-color, #3498db) 30%, transparent);
}

/* Farbiges Initialen-Icon */
.maincat-icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.maincat-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #2c3e50;
}
.maincat-card--active .maincat-name {
    color: var(--mcat-color, #3498db);
}

/* Admin-Buttons in der Karte */
.maincat-admin-btns {
    display: none;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}
.maincat-card:hover .maincat-admin-btns { display: inline-flex; }

.mcat-btn-edit, .mcat-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 3px;
    border-radius: 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
}
.mcat-btn-edit:hover   { background: #fff3cd; opacity: 1; }
.mcat-btn-delete:hover { background: #ffe0e0; opacity: 1; }

/* ============================================================
   UNTERKATEGORIEN — Chips / Pills
   ============================================================ */
.subcat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    margin: 0 5px 0 0;
    border-radius: 999px;
    background: #f4f6f9;
    border: 1.5px solid #dde2ea;
    color: #555;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.subcat-chip:hover {
    background: #e8edf5;
    border-color: #b0bbcc;
    color: #333;
}
.subcat-chip--active {
    background: #1a6fd4;
    border-color: #1a6fd4;
    color: #fff;
    box-shadow: 0 2px 8px rgba(26,111,212,0.28);
    font-weight: 600;
}

.subcat-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
    flex-shrink: 0;
}
.subcat-chip--active .subcat-dot { opacity: 1; background: rgba(255,255,255,0.8); }

.subcat-name { line-height: 1; }

/* Admin-Buttons in Chip */
.subcat-admin-btns {
    display: none;
    align-items: center;
    gap: 1px;
    margin-left: 2px;
}
.subcat-chip:hover .subcat-admin-btns { display: inline-flex; }

.scat-btn-edit, .scat-btn-delete {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.72rem;
    padding: 1px 3px;
    border-radius: 4px;
    line-height: 1;
    opacity: 0.75;
    transition: opacity 0.15s, background 0.15s;
}
.scat-btn-edit:hover   { background: rgba(255,255,255,0.3); opacity: 1; }
.scat-btn-delete:hover { background: rgba(255,50,50,0.15); opacity: 1; }
.subcat-chip--active .scat-btn-edit:hover   { background: rgba(255,255,255,0.25); }
.subcat-chip--active .scat-btn-delete:hover { background: rgba(255,100,100,0.3); }

.subcat-empty {
    font-size: 0.8rem;
    color: #aaa;
    padding: 6px 4px;
    font-style: italic;
}

/* ===== Inline Add-User Form ===== */
.add-user-inline-box {
    background: #f8fafb;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px 14px;
    margin-bottom: 22px;
}
.add-user-inline-box h4 {
    margin: 0 0 14px;
    font-size: 0.95rem;
    color: #2c3e50;
    font-weight: 700;
}
.add-user-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 16px;
    margin-bottom: 14px;
}
.add-user-grid .form-group {
    margin: 0;
}
.add-user-grid label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.add-user-grid input,
.add-user-grid select {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #d0d7e2;
    border-radius: 7px;
    font-size: 0.88rem;
    background: #fff;
    transition: border-color 0.2s;
}
.add-user-grid input:focus,
.add-user-grid select:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}
.btn-add-user {
    padding: 9px 22px;
    font-size: 0.9rem;
    border-radius: 7px;
}
.add-user-msg {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
}
.add-user-msg.msg-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.add-user-msg.msg-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== Super-Admin Role Badge ===== */
.user-badge.super_admin,
.user-role-badge.super_admin {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
    font-weight: 700;
    border: 1.5px solid #d68910;
    box-shadow: 0 2px 6px rgba(243,156,18,0.35);
}

/* ===== Notification Button ===== */
.btn-notification {
    padding: 9px 18px;
    background: #f39c12;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    white-space: nowrap;
}
.btn-notification:hover:not(:disabled) {
    background: #e67e22;
    transform: translateY(-1px);
}
.btn-notification:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}
.btn-notification--active {
    background: #e67e22;
    box-shadow: 0 2px 10px rgba(230,126,34,0.4);
    animation: notif-pulse 2s infinite;
}
.btn-notification--sent {
    background: #27ae60 !important;
    opacity: 1 !important;
}
@keyframes notif-pulse {
    0%, 100% { box-shadow: 0 2px 10px rgba(230,126,34,0.4); }
    50%       { box-shadow: 0 2px 20px rgba(230,126,34,0.7); }
}

/* ===== Logout Warning Modal ===== */
#logoutWarningModal .modal-content {
    border-top: 4px solid #e67e22;
}

/* ============================================================
   RESPONSIVE DESIGN — Mobile & Tablet
   ============================================================ */

/* ===== Tablet (768px - 1024px) ===== */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-left: 200px;
        padding: 16px;
    }
    .content-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .content-header h1 {
        font-size: 1.3rem;
    }
    .content-actions {
        flex-wrap: wrap;
        gap: 6px;
    }
    .btn-notification {
        font-size: 0.8rem;
        padding: 7px 12px;
    }
}

/* ===== Mobile (max 768px) ===== */
@media (max-width: 768px) {

    /* Layout */
    .app-container {
        flex-direction: column;
    }

    /* Sidebar → Bottom Nav on mobile */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 1000;
        flex-direction: column;
        padding: 0;
        box-shadow: 0 -2px 12px rgba(0,0,0,0.2);
    }

    /* Header مضغوط */
    .sidebar-header {
        display: none; /* مخفي على موبايل - شريط التنقل السفلي */
    }

    /* Nav → أفقي في الأسفل */
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 4px 0 6px;
        gap: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }

    .nav-item {
        flex-direction: column;
        align-items: center;
        padding: 6px 10px;
        gap: 2px;
        border-left: none !important;
        border-bottom: 3px solid transparent;
        min-width: 52px;
        font-size: 0;
        border-radius: 0;
    }
    .nav-item.active {
        border-left: none !important;
        border-bottom-color: #3d72d4;
        background: rgba(61,114,212,0.1);
    }
    .nav-icon {
        font-size: 1.3rem;
    }
    /* نص صغير تحت الأيقونة */
    .nav-item span:not(.nav-icon) {
        font-size: 0.6rem;
        opacity: 0.8;
        display: block;
        max-width: 52px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .nav-item.logout span:not(.nav-icon) {
        color: #ff6b6b;
    }

    /* Main content - padding أسفل للـ bottom nav */
    .main-content {
        margin-left: 0;
        padding: 12px 12px 80px 12px;
        width: 100%;
    }

    /* Header */
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 12px;
    }
    .content-header h1 {
        font-size: 1.2rem;
    }
    .content-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .content-actions button {
        flex: 1;
        min-width: 120px;
        font-size: 0.8rem;
        padding: 8px 10px;
    }
    .btn-notification {
        flex: 1 1 100% !important;
        font-size: 0.82rem;
    }

    /* Search bar */
    .search-container {
        flex-direction: column;
        gap: 6px;
    }
    .search-container input {
        width: 100%;
    }
    .search-buttons {
        display: flex;
        gap: 6px;
        width: 100%;
    }
    .search-buttons button {
        flex: 1;
    }

    /* ========================================================
       CATEGORIES — STORY CIRCLES (Mobile Pro Design)
       الإصلاح الجذري: categories-row → block بدل flex
       categories-tabs → scroll container مستقل
       ======================================================== */

    .categories-section {
        margin-bottom: 14px;
        background: #fff;
        border-radius: 18px;
        padding: 14px 0 6px;
        box-shadow: 0 2px 14px rgba(0,0,0,0.08);
    }

    /* إخفاء labels KATEGORIEN / UNTERKATEGORIEN */
    .cat-row-label { display: none !important; }

    /* إلغاء flex في categories-row — لازم block */
    .categories-row {
        display: block !important;
        overflow: visible !important;
        gap: 0 !important;
        padding: 0 !important;
    }

    /* الـ scroll container الحقيقي */
    .categories-tabs,
    .subcategories-tabs {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: visible !important;
        gap: 6px !important;
        padding: 4px 16px 10px !important;
        margin-bottom: 0 !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        min-width: 0;
    }
    .categories-tabs::-webkit-scrollbar,
    .subcategories-tabs::-webkit-scrollbar { display: none; }

    /* === STORY CIRCLES — القوائم الرئيسية === */
    .maincat-card {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        flex-shrink: 0 !important;
        padding: 6px 4px 8px !important;
        gap: 7px !important;
        min-width: 64px !important;
        max-width: 72px !important;
        width: 64px !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        text-align: center;
    }
    .maincat-card:active { opacity: 0.7; transform: scale(0.94); }

    /* الدائرة — مثل Instagram story */
    .maincat-icon {
        width: 52px !important;
        height: 52px !important;
        border-radius: 50% !important;
        font-size: 1rem !important;
        font-weight: 900 !important;
        box-shadow: 0 3px 10px rgba(0,0,0,0.18) !important;
        flex-shrink: 0 !important;
        transition: transform 0.2s, box-shadow 0.2s !important;
        border: 3px solid transparent !important;
        outline: 3px solid #edf0f5 !important;
        outline-offset: 2px !important;
    }

    /* Active: حلقة ملونة حول الدائرة */
    .maincat-card--active .maincat-icon {
        outline-color: var(--mcat-color, #3498db) !important;
        outline-width: 3px !important;
        box-shadow: 0 4px 16px color-mix(in srgb, var(--mcat-color,#3498db) 40%, transparent) !important;
        transform: scale(1.06) !important;
    }

    .maincat-name {
        font-size: 0.65rem !important;
        font-weight: 600 !important;
        color: #667 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 64px !important;
    }
    .maincat-card--active .maincat-name {
        color: var(--mcat-color, #1a6fd4) !important;
        font-weight: 800 !important;
    }

    /* أزرار الإدارة */
    .maincat-admin-btns { display: inline-flex !important; gap: 2px; }
    .mcat-btn-edit, .mcat-btn-delete {
        font-size: 0.6rem; padding: 2px 4px;
        background: rgba(255,255,255,0.95);
        border: 1px solid #dde; border-radius: 4px;
    }

    /* === CHIPS — القوائم الفرعية === */
    .subcat-chip {
        flex-shrink: 0 !important;
        padding: 7px 16px !important;
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        min-height: 34px !important;
        border-radius: 999px !important;
        white-space: nowrap !important;
        transition: background 0.18s, box-shadow 0.18s !important;
    }
    .subcat-chip--active {
        box-shadow: 0 3px 12px rgba(26,111,212,0.35) !important;
    }
    .subcat-admin-btns { display: inline-flex !important; }
    .scat-btn-edit, .scat-btn-delete {
        font-size: 0.65rem; padding: 2px 3px;
        border-radius: 4px; background: rgba(255,255,255,0.25);
    }

    /* فاصل بين الفئات الرئيسية والفرعية */
    .subcat-row {
        border-top: 1px solid #f0f3f8;
        margin-top: 2px;
        padding-top: 4px;
    }

    /* Product cards */
    .product-card {
        padding: 12px;
        margin-bottom: 10px;
        border-radius: 10px;
    }
    .product-header {
        flex-wrap: wrap;
        gap: 6px;
    }
    .product-name {
        font-size: 1rem;
    }
    .product-meta {
        font-size: 0.75rem;
        flex-wrap: wrap;
        gap: 4px;
    }
    .variants-list {
        gap: 4px;
    }
    .variant-readonly {
        padding: 4px 8px;
    }
    .variant-weight-label {
        font-size: 0.82rem;
        min-width: 40px;
    }
    .variant-price-label {
        font-size: 0.82rem;
    }
    .product-controls {
        margin-top: 8px;
    }
    .product-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }
    .product-actions button {
        flex: 1;
        min-width: 100px;
        font-size: 0.8rem;
        padding: 8px;
    }

    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        margin: 5vh auto;
        border-radius: 14px;
        padding: 16px;
    }
    .modal-large {
        width: 98%;
        max-width: 98%;
    }

    /* Edit product modal */
    .settings-grid,
    .add-user-grid {
        grid-template-columns: 1fr !important;
    }

    /* Variant rows in modal */
    .variant-row {
        flex-wrap: wrap;
        gap: 6px;
    }
    .variant-row select.variant-weight {
        flex: 1 1 100%;
    }
    .variant-price-wrapper {
        flex: 1;
    }

    /* Admin panel tabs */
    .admin-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        gap: 4px;
        scrollbar-width: none;
    }
    .tab-btn {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 7px 12px;
    }

    /* Changes log */
    .log-item {
        flex-direction: column;
        gap: 6px;
    }
    .log-time {
        min-width: auto;
    }
    .log-stats {
        gap: 8px;
    }
    .stat-card {
        flex: 1;
        min-width: 80px;
        padding: 10px;
    }
    .stat-value {
        font-size: 1.2rem;
    }

    /* Settings page */
    .settings-page {
        padding: 0 0 20px;
    }
    .settings-card-body {
        padding: 14px;
    }
    .settings-actions {
        flex-direction: column;
    }
    .btn-save, .btn-test {
        width: 100%;
    }

    /* Login page */
    .login-card {
        margin: 20px;
        padding: 30px 20px;
    }

    /* Notification button full width on mobile */
    #btnSendNotification {
        width: 100%;
        margin-top: 4px;
    }
}

/* ===== Very small phones (max 380px) ===== */
@media (max-width: 380px) {
    .nav-item {
        padding: 5px 6px;
        min-width: 44px;
    }
    .nav-icon { font-size: 1.2rem; }
    .nav-item span:not(.nav-icon) { font-size: 0.55rem; }
    .maincat-name { font-size: 0.75rem; }
    .product-name { font-size: 0.95rem; }
}

/* ===== PWA Standalone mode ===== */
@media (display-mode: standalone) {
    /* يعمل كتطبيق - إخفاء بعض العناصر */
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .main-content {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
}

/* ===== Push Notification Button ===== */
.btn-push {
    font-size: 0.82rem;
    padding: 8px 14px;
    white-space: nowrap;
}
@media (max-width: 768px) {
    .btn-push { width: 100%; margin-top: 4px; }
}
