/* ===== VIRTUAL WEIGHMENT PLANT MASTER STYLES ===== */

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

.vw-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 ease;
}

.vw-mini-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

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

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

.vw-mini-stat-icon.primary { background: var(--dash-primary-light); color: var(--dash-primary); }
.vw-mini-stat-icon.success { background: var(--dash-success-light); color: var(--dash-success); }
.vw-mini-stat-icon.warning { background: rgba(245,158,11,0.12); color: #f59e0b; }
.vw-mini-stat-icon.info    { background: var(--dash-cyan-light);    color: var(--dash-cyan); }

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

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

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

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

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

.vw-search-wrapper { position: relative; }

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

.vw-search-wrapper input {
    padding: 0.6rem 0.85rem 0.6rem 2.4rem;
    border: 1px solid var(--dash-border);
    border-radius: 10px;
    background: var(--dash-surface);
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    min-width: 280px;
    transition: all 0.3s ease;
}

.vw-search-wrapper input:focus {
    outline: none;
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.vw-filter-select {
    padding: 0.6rem 2rem 0.6rem 0.85rem;
    border: 1px solid var(--dash-border);
    border-radius: 10px;
    background: var(--dash-surface);
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    transition: all 0.3s ease;
}

.vw-filter-select:focus {
    outline: none;
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.vw-refresh-btn, .vw-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.vw-refresh-btn {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    color: var(--dash-text-secondary);
}

.vw-refresh-btn:hover {
    background: var(--dash-surface-hover);
    color: var(--dash-text-primary);
    border-color: var(--dash-border-hover);
}

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

.vw-refresh-btn.spinning svg {
    animation: vw-spin 1s linear infinite;
}

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

.vw-add-btn {
    background: var(--dash-primary);
    border: 1px solid var(--dash-primary);
    color: #fff;
}

.vw-add-btn:hover {
    background: var(--dash-primary-hover);
    border-color: var(--dash-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--dash-primary-glow);
}

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

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

.vw-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    gap: 0.75rem;
}

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

.vw-loading-text {
    font-size: 0.85rem;
    color: var(--dash-text-secondary);
    font-weight: 500;
}

.vw-sort-header {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.vw-sort-header:hover { color: var(--dash-primary); }

.vw-sort-header::after {
    content: ' ↕';
    font-size: 0.7rem;
    opacity: 0.4;
}

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

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

/* Badge styles */
.vw-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.vw-status-badge.active {
    background: var(--dash-success-light);
    color: var(--dash-success);
    border: 1px solid rgba(16,185,129,0.25);
}

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

.vw-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Action buttons */
.vw-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vw-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface-hover);
    color: var(--dash-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vw-action-btn:hover {
    border-color: var(--dash-primary);
    color: var(--dash-primary);
    background: var(--dash-primary-light);
}

.vw-action-btn.toggle:hover {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245,158,11,0.12);
}

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

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

/* Empty state */
.vw-empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1rem;
    text-align: center;
}

.vw-empty-state.visible { display: flex; }

.vw-empty-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--dash-surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--dash-text-muted);
}

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

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

.vw-empty-desc {
    font-size: 0.82rem;
    color: var(--dash-text-muted);
    max-width: 320px;
}

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

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

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

.vw-page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    color: var(--dash-text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.vw-page-btn:hover:not(:disabled) {
    background: var(--dash-surface-hover);
    color: var(--dash-text-primary);
    border-color: var(--dash-border-hover);
}

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

.vw-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Modal Styles --- */
.vw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.vw-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.vw-modal {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 16px;
    width: 92%;
    max-width: 640px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.vw-modal-overlay.active .vw-modal {
    transform: scale(1) translateY(0);
}

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

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

.vw-modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--dash-primary-light);
    color: var(--dash-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vw-modal-icon svg { width: 20px; height: 20px; }

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

.vw-modal-subtitle {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    margin: 0.15rem 0 0 0;
}

.vw-modal-close {
    background: none;
    border: none;
    color: var(--dash-text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.vw-modal-close:hover {
    background: var(--dash-surface-hover);
    color: var(--dash-text-primary);
}

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

.vw-modal-body {
    padding: 1.5rem;
    max-height: calc(85vh - 140px);
    overflow-y: auto;
}

.vw-form-section {
    margin-bottom: 1.25rem;
}

.vw-form-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--dash-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

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

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

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

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

.vw-form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dash-text-secondary);
}

.vw-required { color: #ef4444; }

.vw-form-group input,
.vw-form-group select {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--dash-border);
    border-radius: 8px;
    background: var(--dash-surface-2, var(--dash-surface));
    color: var(--dash-text-primary);
    font-size: 0.82rem;
    transition: all 0.25s ease;
    width: 100%;
}

.vw-form-group input:focus,
.vw-form-group select:focus {
    outline: none;
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

/* Autocomplete Container */
.vw-autocomplete {
    position: relative;
    width: 100%;
}

.vw-autocomplete input {
    width: 100%;
    padding-right: 2rem;
}

.vw-autocomplete-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--dash-text-muted);
    cursor: pointer;
    display: none;
    padding: 2px;
}

.vw-autocomplete-clear:hover { color: var(--dash-text-primary); }

.vw-autocomplete-clear.active { display: block; }

.vw-autocomplete-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.vw-autocomplete-list.active {
    display: block;
}

.vw-autocomplete-item {
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
    color: var(--dash-text-primary);
    cursor: pointer;
    border-bottom: 1px solid var(--dash-border);
    transition: background 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.vw-autocomplete-item:last-child { border-bottom: none; }

.vw-autocomplete-item:hover,
.vw-autocomplete-item.highlighted {
    background: var(--dash-primary-light);
    color: var(--dash-primary);
}

.vw-autocomplete-item-title {
    font-weight: 600;
    line-height: 1.2;
}

.vw-autocomplete-item-sub {
    font-size: 0.72rem;
    color: var(--dash-text-muted);
}

.vw-autocomplete-loading,
.vw-autocomplete-empty {
    padding: 0.85rem;
    font-size: 0.8rem;
    color: var(--dash-text-muted);
    text-align: center;
}

/* Selection preview badge */
.vw-preview-card {
    background: var(--dash-surface-hover);
    border: 1px dashed var(--dash-border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.vw-preview-badge {
    padding: 0.35rem 0.75rem;
    background: var(--dash-primary-light);
    color: var(--dash-primary);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.vw-preview-text {
    font-size: 0.82rem;
    color: var(--dash-text-secondary);
}

.vw-preview-text strong {
    color: var(--dash-text-primary);
}

.vw-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.1rem 1.5rem;
    border-top: 1px solid var(--dash-border);
    background: var(--dash-surface-hover);
}

.vw-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vw-btn-secondary {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    color: var(--dash-text-secondary);
}

.vw-btn-secondary:hover {
    background: var(--dash-surface-hover);
    color: var(--dash-text-primary);
}

.vw-btn-primary {
    background: var(--dash-primary);
    border: 1px solid var(--dash-primary);
    color: #fff;
}

.vw-btn-primary:hover {
    background: var(--dash-primary-hover);
    border-color: var(--dash-primary-hover);
    box-shadow: 0 4px 14px var(--dash-primary-glow);
}

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

/* --- Toast --- */
.vw-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    z-index: 1100;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.vw-toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.vw-toast.success { border-left: 4px solid var(--dash-success); }
.vw-toast.error   { border-left: 4px solid #ef4444; }
.vw-toast.info    { border-left: 4px solid var(--dash-cyan); }

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

@keyframes vw-toastOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* --- Responsive --- */
@media (max-width: 992px) {
    .vw-mini-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .vw-mini-stats { grid-template-columns: 1fr; }
    .vw-form-grid-2 { grid-template-columns: 1fr; }
    .vw-search-wrapper input { min-width: 100%; width: 100%; }
    .vw-toolbar { flex-direction: column; align-items: stretch; }
    .vw-toolbar-left, .vw-toolbar-right { width: 100%; }
}

@media (max-width: 480px) {
    .vw-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .vw-panel {
        border-radius: 8px;
    }

    .vw-actions {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .vw-modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .vw-modal-footer button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 380px) {
    .vw-toolbar {
        gap: 0.4rem;
    }
}
