
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --accent: #0EA5E9;
    --accent-light: #E0F2FE;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --success: #10B981;
    --success-light: #ECFDF5;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 30px -10px rgba(15, 23, 42, 0.16);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 90px;
    -webkit-font-smoothing: antialiased;
}

.material-symbols-outlined {
    font-weight: 500;
    font-style: normal;
    font-size: 24px;
    display: inline-block;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    direction: ltr;
}
/* Header Navbar */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.header-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Connection Badge in Header */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: background 0.3s;
}

.status-badge.online {
    background: var(--success-light);
    color: #065F46;
    border-color: #A7F3D0;
}

    .status-badge.online .status-dot {
        background: var(--success);
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
        animation: pulse 2s infinite;
    }

.status-badge.offline {
    background: var(--danger-light);
    color: #991B1B;
    border-color: #FECACA;
}

    .status-badge.offline .status-dot {
        background: var(--danger);
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
    }

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* Layout Container */
.container {
    max-width: 960px;
    margin: 16px auto;
    padding: 0 12px;
}

.hidden {
    display: none !important;
}

/* Search Input */
.search-wrap {
    position: relative;
    margin-bottom: 20px;
}

    .search-wrap .material-symbols-outlined {
        position: absolute;
        right: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
        font-size: 20px;
    }

.search-input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    outline: none;
    transition: all 0.2s ease;
}

    .search-input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    }

.section-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* Grid Categories: 2 items per row on mobile & tablet */
.grid-categories {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 640px) {
    .grid-categories {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 16px;
    }
}

.category-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 12px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    transition: all 0.2s ease;
}

    .category-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-md);
        border-color: var(--primary);
    }

.category-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
    background: var(--primary-light);
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.category-name {
    font-weight: 800;
    font-size: 0.98rem;
    color: var(--text-main);
    margin-bottom: 6px;
    word-break: break-word;
}

.category-count {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 3px 10px;
    border-radius: 20px;
}

.category-actions {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    gap: 2px;
}

/* Buttons & Action Items */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

    .icon-btn:hover {
        background: var(--bg);
        color: var(--primary);
    }

    .icon-btn.danger:hover {
        background: var(--danger-light);
        color: var(--danger);
    }

    .icon-btn.success:hover {
        background: var(--success-light);
        color: var(--success);
    }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 3px 10px rgba(79, 70, 229, 0.2);
}

    .btn-primary:hover {
        background: var(--primary-hover);
    }

.btn-secondary {
    background: var(--bg);
    color: var(--text-main);
    border: 1.5px solid var(--border);
}

    .btn-secondary:hover {
        background: var(--border);
    }

.btn-danger {
    background: var(--danger);
    color: white;
}

    .btn-danger:hover {
        background: #DC2626;
    }

.btn-trash {
    background: var(--warning-light);
    color: #B45309;
    border: 1px solid #FDE68A;
}

    .btn-trash:hover {
        background: #FEF3C7;
    }

/* Back Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    cursor: pointer;
    margin-bottom: 14px;
    transition: all 0.2s ease;
}

    .btn-back:hover {
        background: var(--primary-light);
        border-color: var(--primary);
        color: var(--primary);
    }

/* Category Header Info */
.category-header-box {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.cat-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.stat-badge {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

    .stat-badge.items {
        background: var(--primary-light);
        color: var(--primary);
    }

    .stat-badge.qty {
        background: var(--accent-light);
        color: #0369A1;
    }

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
    font-size: 0.9rem;
}

th {
    background: #F1F5F9;
    color: var(--text-muted);
    font-weight: 800;
    padding: 12px 14px;
    border-bottom: 1.5px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #FAF5FF;
}

.badge-quantity {
    background: var(--accent-light);
    color: #0369A1;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
}

/* Search Results */
.search-result-item {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    border: 1.5px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    left: 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 12px 20px;
    font-size: 0.95rem;
    font-weight: 800;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 40;
    transition: all 0.2s ease;
}

    .fab:hover {
        background: var(--primary-hover);
        transform: scale(1.03);
    }

/* Modal Dialogs */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 14px;
}

    .modal-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-backdrop.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 14px;
}

    .form-group label {
        display: block;
        margin-bottom: 5px;
        font-weight: 700;
        font-size: 0.88rem;
        color: var(--text-muted);
    }

.form-control {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    font-size: 0.92rem;
    outline: none;
    background: #F8FAFC;
    color: var(--text-main);
    transition: all 0.2s ease;
}

    .form-control:focus {
        border-color: var(--primary);
        background: var(--surface);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    }

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

    .modal-actions .btn {
        flex: 1;
    }

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-main);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.88rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.3s forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
}

    .empty-state .material-symbols-outlined {
        font-size: 3rem;
        color: var(--border);
        margin-bottom: 8px;
    }

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 24px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}