/* ===== MATERIAL MASTER STYLES ===== */

/* --- Mini Stat Cards --- */
.mat-mini-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mat-mini-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    padding: 1.1rem 1.25rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.mat-mini-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: rgba(99, 102, 241, 0.3);
}

.mat-mini-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mat-mini-stat-icon svg {
    width: 22px;
    height: 22px;
}

.mat-mini-stat-icon.primary {
    background: var(--dash-primary-light, rgba(99, 102, 241, 0.12));
    color: var(--dash-primary, #6366f1);
}

.mat-mini-stat-icon.success {
    background: var(--dash-success-light, rgba(16, 185, 129, 0.12));
    color: var(--dash-success, #10b981);
}

.mat-mini-stat-icon.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.mat-mini-stat-icon.amber {
    background: rgba(249, 115, 22, 0.12);
    color: #f97316;
}

.mat-mini-stat-content {
    display: flex;
    flex-direction: column;
}

.mat-mini-stat-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--dash-text-primary);
    line-height: 1.2;
}

.mat-mini-stat-label {
    font-size: 0.72rem;
    color: var(--dash-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* --- Toolbar --- */
.mat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.mat-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    flex: 1;
}

.mat-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mat-search-wrapper {
    position: relative;
    min-width: 260px;
    flex: 1;
    max-width: 380px;
}

.mat-search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--dash-text-muted);
    pointer-events: none;
}

.mat-search-wrapper input {
    width: 100%;
    height: 40px;
    padding: 0 14px 0 38px;
    border-radius: 10px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    outline: none;
    transition: all 0.25s ease;
}

.mat-search-wrapper input:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light, rgba(99, 102, 241, 0.18));
}

.mat-filter-select {
    height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    outline: none;
}

.mat-filter-select:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light, rgba(99, 102, 241, 0.18));
}

.mat-refresh-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.mat-refresh-btn svg {
    width: 18px;
    height: 18px;
}

.mat-refresh-btn:hover {
    background: var(--dash-primary);
    color: #fff;
    border-color: var(--dash-primary);
}

.mat-refresh-btn.spinning svg {
    animation: mat-spin 0.8s linear infinite;
}

@keyframes mat-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mat-add-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--dash-primary, #6366f1), var(--dash-primary-hover, #4f46e5));
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.mat-add-btn svg {
    width: 16px;
    height: 16px;
}

.mat-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

/* --- Panel & Table --- */
.mat-panel {
    position: relative;
    overflow: hidden;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
}

.mat-sort-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.mat-sort-header::after {
    content: ' ↕';
    opacity: 0.35;
    font-size: 0.75rem;
}

.mat-sort-header.sort-asc::after {
    content: ' ↑';
    opacity: 1;
    color: var(--dash-primary);
}

.mat-sort-header.sort-desc::after {
    content: ' ↓';
    opacity: 1;
    color: var(--dash-primary);
}

/* Badges */
.mat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.mat-badge-active {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.mat-badge-inactive {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.mat-badge-packing {
    background: rgba(249, 115, 22, 0.12);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.mat-badge-standard {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
    border: 1px solid rgba(100, 116, 139, 0.25);
}

.mat-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--dash-text-primary);
    font-size: 0.74rem;
    font-weight: 600;
    border: 1px solid rgba(99, 102, 241, 0.18);
}

.mat-chip-plant {
    background: rgba(6, 182, 212, 0.08);
    border-color: rgba(6, 182, 212, 0.2);
    color: #0891b2;
}

.mat-code-pill {
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: 700;
    color: var(--dash-primary);
    background: var(--dash-primary-light, rgba(99, 102, 241, 0.1));
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* Action Buttons */
.mat-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--dash-border);
    background: transparent;
    color: var(--dash-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mat-action-btn svg {
    width: 15px;
    height: 15px;
}

.mat-action-btn:hover {
    background: var(--dash-surface-hover, rgba(255, 255, 255, 0.06));
    color: var(--dash-text-primary);
    border-color: var(--dash-primary);
}

.mat-action-btn.edit:hover {
    background: var(--dash-primary-light, rgba(99, 102, 241, 0.15));
    color: var(--dash-primary);
    border-color: var(--dash-primary);
}

.mat-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: #ef4444;
}

.mat-action-btn.activate:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border-color: #10b981;
}

/* Empty State */
.mat-empty-state {
    display: none;
    padding: 3.5rem 1.5rem;
    text-align: center;
}

.mat-empty-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--dash-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.mat-empty-icon svg {
    width: 28px;
    height: 28px;
}

.mat-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dash-text-primary);
    margin-bottom: 0.3rem;
}

.mat-empty-desc {
    font-size: 0.82rem;
    color: var(--dash-text-muted);
}

/* Pagination */
.mat-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--dash-border);
}

.mat-page-info {
    font-size: 0.78rem;
    color: var(--dash-text-muted);
    font-weight: 500;
}

.mat-pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.mat-page-btn {
    min-width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text-primary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mat-page-btn:hover:not(:disabled):not(.active) {
    background: var(--dash-primary-light, rgba(99, 102, 241, 0.12));
    color: var(--dash-primary);
    border-color: var(--dash-primary);
}

.mat-page-btn.active {
    background: var(--dash-primary);
    color: #fff;
    border-color: var(--dash-primary);
}

.mat-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.mat-page-dots {
    font-size: 0.78rem;
    color: var(--dash-text-muted);
    padding: 0 3px;
}

/* Loading Overlay */
.mat-loading-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: var(--dash-radius);
}

.mat-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--dash-border);
    border-top-color: var(--dash-primary);
    border-radius: 50%;
    animation: mat-spin 0.8s linear infinite;
}

.mat-loading-text {
    font-size: 0.84rem;
    color: var(--dash-text-primary);
    font-weight: 600;
}

/* ========== MODAL ========== */
.mat-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.mat-modal-overlay.active {
    display: flex;
    animation: mat-fadeIn 0.25s ease-out;
}

@keyframes mat-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mat-modal {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4);
    animation: mat-slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mat-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.mat-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--dash-border);
}

.mat-modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.mat-modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--dash-primary-light, rgba(99, 102, 241, 0.15));
    color: var(--dash-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mat-modal-icon svg {
    width: 22px;
    height: 22px;
}

.mat-modal-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--dash-text-primary);
    margin: 0;
}

.mat-modal-subtitle {
    font-size: 0.76rem;
    color: var(--dash-text-muted);
    margin: 2px 0 0;
}

.mat-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--dash-border);
    background: transparent;
    color: var(--dash-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mat-modal-close svg {
    width: 18px;
    height: 18px;
}

.mat-modal-close:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: #ef4444;
}

.mat-modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Sections */
.mat-form-section {
    margin-bottom: 1.5rem;
}

.mat-form-section:last-child {
    margin-bottom: 0.5rem;
}

.mat-form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--dash-text-primary);
    margin-bottom: 0.85rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px dashed var(--dash-border);
}

.mat-form-section-title svg {
    width: 16px;
    height: 16px;
    color: var(--dash-primary);
}

.mat-form-grid {
    display: grid;
    gap: 0.85rem 1rem;
}

.mat-form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mat-form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.mat-form-grid-1 {
    grid-template-columns: 1fr;
}

@media (max-width: 768px) {
    .mat-form-grid-3, .mat-form-grid-2 {
        grid-template-columns: 1fr;
    }
}

.mat-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mat-form-group label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--dash-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mat-required {
    color: #ef4444;
}

.mat-form-group input,
.mat-form-group select,
.mat-form-group textarea {
    height: 40px;
    padding: 0 12px;
    border-radius: 9px;
    border: 1px solid var(--dash-border);
    background: var(--dash-bg, #0b0f19);
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    outline: none;
    transition: all 0.25s ease;
}

.mat-form-group textarea {
    height: 72px;
    padding: 8px 12px;
    resize: vertical;
}

.mat-form-group input:focus,
.mat-form-group select:focus,
.mat-form-group textarea:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light, rgba(99, 102, 241, 0.18));
}

/* Packing Material Feature Card (Checkbox 1 or 0) */
.mat-packing-box {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.08), rgba(234, 88, 12, 0.03));
    border: 1px solid rgba(249, 115, 22, 0.25);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: all 0.3s ease;
}

.mat-packing-box:hover {
    border-color: rgba(249, 115, 22, 0.45);
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.12), rgba(234, 88, 12, 0.05));
}

.mat-packing-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.mat-packing-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mat-packing-icon svg {
    width: 20px;
    height: 20px;
}

.mat-packing-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--dash-text-primary);
}

.mat-packing-subtitle {
    font-size: 0.72rem;
    color: var(--dash-text-muted);
}

/* Switch UI */
.mat-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.mat-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mat-switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--dash-border);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
}

.mat-switch-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mat-switch input:checked + .mat-switch-slider {
    background-color: #f97316;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.45);
}

.mat-switch input:checked + .mat-switch-slider:before {
    transform: translateX(24px);
}

/* Modal Footer */
.mat-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--dash-border);
}

.mat-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
}

.mat-btn svg {
    width: 16px;
    height: 16px;
}

.mat-btn-secondary {
    background: transparent;
    border: 1px solid var(--dash-border);
    color: var(--dash-text-muted);
}

.mat-btn-secondary:hover {
    background: var(--dash-surface-hover, rgba(255, 255, 255, 0.05));
    color: var(--dash-text-primary);
    border-color: var(--dash-text-muted);
}

.mat-btn-primary {
    background: linear-gradient(135deg, var(--dash-primary), var(--dash-primary-hover));
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.mat-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

/* Toast */
.mat-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 0.75rem;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

.mat-toast.show {
    display: flex;
    animation: mat-toastIn 0.3s ease-out forwards;
}

@keyframes mat-toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes mat-toastOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

.mat-toast.success {
    border-left: 4px solid #10b981;
}

.mat-toast.error {
    border-left: 4px solid #ef4444;
}

.mat-toast.warning {
    border-left: 4px solid #f59e0b;
}

.mat-toast.info {
    border-left: 4px solid var(--dash-primary);
}

.mat-toast-icon {
    font-size: 1.15rem;
}

.mat-toast-message {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--dash-text-primary);
}
