﻿/* ==========================================================================
   Ofooqx (أُفق) - Stock Management Theme (Dark Mode Supported)
   ========================================================================== */

:host {
    display: block;
    width: 100%;
}

.ofooqx-page-container {
    padding: 1.25rem;
    width: 100%;
    box-sizing: border-box;
    color: var(--text-main, #1e293b);
    direction: rtl;
}

/* Header */
.ofooqx-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.ofooqx-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main, #006837);
}

.ofooqx-subtitle {
    margin: 0.2rem 0 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #64748b);
}

/* Primary Button (Blue & Bold) */
.btn-ofooqx-primary {
    background-color: var(--accent, #2563eb);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

    .btn-ofooqx-primary:hover:not(:disabled) {
        background-color: #1d4ed8;
        transform: translateY(-1px);
    }

    .btn-ofooqx-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
        box-shadow: none;
    }

/* Secondary / Cancel Button */
.btn-ofooqx-cancel {
    background-color: var(--btn-cancel-bg, #f1f5f9);
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 8px;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

    .btn-ofooqx-cancel:hover {
        background-color: var(--btn-cancel-hover, #e2e8f0);
    }

/* Stat Cards Grid */
.ofooqx-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.ofooqx-card-stat {
    background: var(--bg-side, #ffffff);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

    .ofooqx-card-stat.border-purple {
        border-right: 4px solid #7c3aed;
    }

    .ofooqx-card-stat.border-warning {
        border-right: 4px solid #f59e0b;
    }

    .ofooqx-card-stat.border-danger {
        border-right: 4px solid #ef4444;
    }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted, #64748b);
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.text-dark {
    color: var(--text-main, #006837);
}

.text-warning {
    color: #f59e0b;
}

.text-danger {
    color: #ef4444;
}

/* Panel & Table Structure */
.ofooqx-panel {
    background: var(--bg-side, #ffffff);
    border-radius: 10px;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.ofooqx-panel-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #f1f5f9);
}

.search-box {
    position: relative;
    max-width: 320px;
}

.search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #94a3b8);
}

.search-box input {
    width: 100%;
    padding: 0.45rem 2.25rem 0.45rem 0.75rem;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    background: var(--bg-app, #ffffff);
    color: var(--text-main, #006837);
    box-sizing: border-box;
    transition: border-color 0.2s;
}

    .search-box input:focus {
        border-color: var(--accent, #2563eb);
    }

.table-container {
    width: 100%;
    overflow-x: auto;
}

.ofooqx-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    font-size: 0.875rem;
}

    .ofooqx-table th {
        background: var(--bg-app, #f8fafc);
        color: var(--text-muted, #475569);
        font-weight: 600;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color, #e2e8f0);
        white-space: nowrap;
    }

    .ofooqx-table td {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color, #f1f5f9);
        color: var(--text-main, #006837);
        vertical-align: middle;
    }

.product-name-cell {
    font-weight: 600;
    color: var(--text-main, #006837);
    text-align: right;
}

/* Badges */
.badge-stock {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-ok {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-low {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.badge-out {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Table Action Buttons */
.table-actions-group {
    display: inline-flex;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    overflow: hidden;
}

.act-btn {
    background: var(--bg-side, #ffffff);
    border: none;
    border-left: 1px solid var(--border-color, #cbd5e1);
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    transition: background-color 0.15s;
}

    .act-btn:last-child {
        border-left: none;
    }

.act-add {
    color: #22c55e;
}

    .act-add:hover {
        background: rgba(34, 197, 94, 0.1);
    }

.act-remove {
    color: #ef4444;
}

    .act-remove:hover {
        background: rgba(239, 68, 68, 0.1);
    }

.act-adjust {
    color: #f59e0b;
}

    .act-adjust:hover {
        background: rgba(245, 158, 11, 0.1);
    }

/* Modals Centered Fixed */
.ofooqx-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(3px);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
}

.ofooqx-modal-box {
    background: var(--bg-side, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    margin: auto;
}

.modal-box-header {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #f1f5f9);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .modal-box-header h5 {
        margin: 0;
        font-size: 1rem;
        font-weight: 700;
        color: var(--text-main, #006837);
    }

.close-x {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted, #64748b);
    cursor: pointer;
}

.modal-box-body {
    padding: 1.25rem;
}

.product-tag-info {
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent, #2563eb);
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.form-field {
    margin-bottom: 0.85rem;
}

    .form-field label {
        display: block;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--text-main, #475569);
        margin-bottom: 0.3rem;
    }

.ofooqx-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-app, #ffffff);
    color: var(--text-main, #006837);
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

    .ofooqx-input:focus {
        border-color: var(--accent, #2563eb);
    }

.modal-box-footer {
    padding: 0.85rem 1.25rem;
    background: var(--bg-app, #f8fafc);
    border-top: 1px solid var(--border-color, #f1f5f9);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* States & Loaders */
.state-container {
    padding: 2.5rem;
    text-align: center;
    color: var(--text-muted, #64748b);
}

.empty-icon {
    font-size: 2rem;
    opacity: 0.5;
    display: block;
    margin-bottom: 0.5rem;
}

.spinner-purple {
    width: 26px;
    height: 26px;
    border: 3px solid var(--border-color, #e2e8f0);
    border-top-color: var(--accent, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 0.5rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

/* ==========================================================================
   Explicit Dark Mode Overrides (Explicit Fallback Selectors)
   ========================================================================== */
[data-theme="dark"],
body.dark-mode {
    --bg-app: #006837;
    --bg-side: #1e293b;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --btn-cancel-bg: #334155;
    --btn-cancel-hover: #475569;
}
