/* ==========================================================================
   BUTTONS, BADGES & INPUTS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.25;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: #0F172A;
    color: #FFFFFF;
}

.btn-primary:hover {
    background: #1E293B;
}

.btn-secondary {
    background: #FFFFFF;
    color: #1E293B;
    border-color: #CBD5E1;
}

.btn-secondary:hover {
    background: #F8FAFC;
    border-color: #94A3B8;
}

.btn-success {
    background: var(--success);
    color: #FFFFFF;
}

.btn-success:hover {
    background: var(--success-hover);
}

.btn-warning {
    background: var(--warning-light);
    color: var(--warning-text);
    border-color: #FDE68A;
}

.btn-danger {
    background: var(--danger-light);
    color: var(--danger-text);
    border-color: #FECACA;
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 6px;
}

.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 5px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}

.badge-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.badge-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.badge-danger { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.badge-primary { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.badge-info { background: #F0F9FF; color: #0369A1; border: 1px solid #BAE6FD; }
.badge-purple { background: #F5F3FF; color: #5B21B6; border: 1px solid #DDD6FE; }
.badge-neutral { background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; }

/* Forms & Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 7px 11px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

textarea.form-control {
    min-height: 68px;
    resize: vertical;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.search-box {
    position: relative;
    min-width: 240px;
    flex: 1;
    max-width: 380px;
}

.search-box input {
    width: 100%;
    padding: 7px 12px 7px 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    font-family: inherit;
    font-size: 12.5px;
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* Sub-tabs */
.sub-tabs {
    display: inline-flex;
    background: #F1F5F9;
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 2px;
    border: 1px solid var(--border);
}

.sub-tab {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sub-tab.active {
    background: var(--bg-surface);
    color: var(--text-main);
    box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.data-table th {
    background: #F8FAFC;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-main);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #F8FAFC;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Progress Bars */
.progress-track {
    width: 100%;
    height: 6px;
    background: #E2E8F0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 999px;
}

/* ==========================================================================
   MODALS & TOASTS
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
}

.modal-dialog {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.modal-dialog.modal-lg {
    max-width: 960px;
}

.modal-dialog.modal-xl {
    max-width: 1220px;
    width: 96vw;
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFFFFF;
}

.modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.modal-body {
    padding: 18px 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #F8FAFC;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 380px;
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

/* Privilege Grid */
.priv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.priv-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-surface-soft);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.priv-item:hover {
    border-color: var(--primary);
}

.priv-item input[type="checkbox"], .priv-item input[type="radio"] {
    accent-color: #0F172A;
}

/* Attendance Pills */
.att-pills {
    display: inline-flex;
    gap: 3px;
    background: #F1F5F9;
    padding: 2px;
    border-radius: 6px;
    border: 1px solid #CBD5E1;
}

.att-pill {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.att-pill.active.present { background: #059669; color: #fff; }
.att-pill.active.absent { background: #DC2626; color: #fff; }
.att-pill.active.sick { background: #D97706; color: #fff; }
.att-pill.active.leave { background: #2563EB; color: #fff; }
.att-pill.active.off { background: #475569; color: #fff; }


/* ==================== SEARCHABLE PRODUCT AUTOCOMPLETE / PICKER ==================== */
.product-picker {
    position: relative;
    width: 100%;
}

.product-picker-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.product-picker-icon {
    position: absolute;
    left: 9px;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    z-index: 2;
}

.product-picker-input {
    padding-left: 30px !important;
    padding-right: 28px !important;
    width: 100%;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    background: #ffffff;
}

.product-picker-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.product-picker-input.has-selection {
    font-weight: 600;
    color: var(--text-main);
    background-color: #F8FAFC;
    border-color: #CBD5E1;
}

.product-picker-clear {
    position: absolute;
    right: 7px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
    transition: all var(--transition-fast);
    padding: 0;
    z-index: 2;
}

.product-picker-clear:hover {
    background: var(--bg-surface-hover);
    color: var(--danger);
}

.product-picker-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    margin-top: 3px;
    min-height: 16px;
    color: var(--text-muted);
    padding: 0 2px;
}

.product-picker-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    max-height: 230px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    padding: 4px;
}

.product-picker-dropdown.open-up {
    top: auto !important;
    bottom: calc(100% + 4px) !important;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.15) !important;
}

.product-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    gap: 8px;
    user-select: none;
}

.product-picker-item:hover,
.product-picker-item.active {
    background: var(--primary-light);
}

.product-picker-item.active .product-picker-item-name {
    color: var(--primary-dark);
}

.product-picker-item-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.product-picker-item-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-picker-item-name mark {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary-dark);
    font-weight: 700;
    padding: 0 1px;
    border-radius: 2px;
}

.product-picker-item-cat {
    font-size: 11px;
    color: var(--text-muted);
}

.product-picker-item-stock {
    flex-shrink: 0;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    display: flex;
    align-items: center;
    gap: 4px;
}

.product-picker-stock-tag {
    padding: 2px 7px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
}

.product-picker-stock-tag.in-stock {
    background: var(--success-light);
    color: var(--success-text);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.product-picker-stock-tag.low-stock {
    background: var(--warning-light);
    color: var(--warning-text);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.product-picker-stock-tag.zero-stock {
    background: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.product-picker-empty {
    padding: 12px 14px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}


