/* ===== STO ORDERS PAGE STYLES ===== */

/* --- Toolbar --- */
.sto-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.sto-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sto-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Search */
.sto-search-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    padding: 0 0.875rem;
    transition: var(--dash-transition);
    min-width: 280px;
}

.sto-search-wrapper:focus-within {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.sto-search-wrapper svg {
    width: 16px;
    height: 16px;
    color: var(--dash-text-muted);
    flex-shrink: 0;
}

.sto-search-wrapper input {
    background: none;
    border: none;
    outline: none;
    color: var(--dash-text);
    font-size: 0.838rem;
    font-family: 'Inter', sans-serif;
    padding: 0.625rem 0;
    width: 100%;
}

.sto-search-wrapper input::placeholder {
    color: var(--dash-text-muted);
}

/* Filters */
.sto-filter-select {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    color: var(--dash-text-secondary);
    font-size: 0.813rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    outline: none;
    cursor: pointer;
    transition: var(--dash-transition);
    appearance: none;
    -webkit-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='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.sto-filter-select:hover {
    border-color: var(--dash-border-hover);
}

.sto-filter-select:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
}

.sto-filter-select option {
    background: var(--dash-surface);
    color: var(--dash-text);
}

/* Counts */
.sto-count-pills {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sto-count-pill {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-text-secondary);
}

.sto-count-pill .count-val {
    color: var(--dash-primary);
    font-weight: 700;
}

/* Refresh Button */
.sto-refresh-btn {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    color: var(--dash-text-secondary);
    padding: 0.5rem;
    border-radius: var(--dash-radius-sm);
    cursor: pointer;
    transition: var(--dash-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sto-refresh-btn:hover {
    border-color: var(--dash-primary);
    color: var(--dash-primary);
}

.sto-refresh-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.sto-refresh-btn.spinning svg {
    animation: sto-spin 1s linear infinite;
}

@keyframes sto-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Panel --- */
.sto-orders-panel {
    position: relative;
}

/* Loading Overlay */
.sto-loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10;
    align-items: center;
    justify-content: center;
    border-radius: var(--dash-radius);
    flex-direction: column;
    gap: 1rem;
}

.sto-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--dash-primary);
    border-radius: 50%;
    animation: sto-spin 0.8s linear infinite;
}

.sto-loading-text {
    font-size: 0.838rem;
    color: var(--dash-text-secondary);
    font-weight: 500;
}

/* --- Table Enhancements --- */
.sto-sort-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color 0.2s ease;
}

.sto-sort-header:hover {
    color: var(--dash-primary);
}

.sto-sort-header::after {
    content: '↕';
    margin-left: 4px;
    font-size: 0.625rem;
    opacity: 0.4;
}

.sto-sort-header.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--dash-primary);
}

.sto-sort-header.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--dash-primary);
}

/* Material Cell */
.sto-material-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sto-mat-code {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--dash-text);
}

.sto-mat-desc {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Plant Cell */
.sto-plant-cell {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.sto-plant-from {
    color: var(--dash-info);
    font-weight: 600;
    font-size: 0.813rem;
}

.sto-plant-to {
    color: var(--dash-success);
    font-weight: 600;
    font-size: 0.813rem;
}

/* Quantity */
.sto-qty {
    font-weight: 700;
    color: var(--dash-text);
    font-size: 0.875rem;
}

.sto-uom {
    font-size: 0.688rem;
    color: var(--dash-text-muted);
    margin-left: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Item Badge */
.sto-item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    background: var(--dash-surface-2);
    border: 1px solid var(--dash-border);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-text-secondary);
    font-family: 'Inter', monospace;
}

/* Doc Type Badge */
.sto-doctype-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sto-doctype-badge.ub {
    background: var(--dash-cyan-light);
    color: var(--dash-cyan);
}

.sto-doctype-badge.nb {
    background: var(--dash-violet-light);
    color: var(--dash-violet);
}

/* --- Pagination --- */
.sto-pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--dash-border);
}

.sto-page-info {
    font-size: 0.813rem;
    color: var(--dash-text-muted);
    font-weight: 500;
}

.sto-pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.sto-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    background: var(--dash-surface-2);
    border: 1px solid var(--dash-border);
    border-radius: 8px;
    color: var(--dash-text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--dash-transition);
}

.sto-page-btn:hover:not(:disabled) {
    border-color: var(--dash-primary);
    color: var(--dash-primary);
    background: var(--dash-primary-light);
}

.sto-page-btn.active {
    background: var(--dash-primary);
    border-color: var(--dash-primary);
    color: white;
}

.sto-page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sto-page-dots {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    padding: 0 2px;
}

/* --- Empty State --- */
.sto-empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
}

.sto-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--dash-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.sto-empty-icon svg {
    width: 28px;
    height: 28px;
    color: var(--dash-text-muted);
}

.sto-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dash-text);
    margin-bottom: 0.375rem;
}

.sto-empty-desc {
    font-size: 0.838rem;
    color: var(--dash-text-muted);
}

/* --- Stats Mini Cards --- */
.sto-mini-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sto-mini-stat {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: var(--dash-transition);
    animation: dash-fadeUp 0.4s ease-out both;
}

.sto-mini-stat:nth-child(1) {
    animation-delay: 0.05s;
}

.sto-mini-stat:nth-child(2) {
    animation-delay: 0.1s;
}

.sto-mini-stat:nth-child(3) {
    animation-delay: 0.15s;
}

.sto-mini-stat:nth-child(4) {
    animation-delay: 0.2s;
}

.sto-mini-stat:hover {
    border-color: var(--dash-border-hover);
    transform: translateY(-1px);
}

.sto-mini-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sto-mini-stat-icon svg {
    width: 20px;
    height: 20px;
}

.sto-mini-stat-icon.primary {
    background: var(--dash-primary-light);
    color: var(--dash-primary);
}

.sto-mini-stat-icon.info {
    background: var(--dash-info-light);
    color: var(--dash-info);
}

.sto-mini-stat-icon.success {
    background: var(--dash-success-light);
    color: var(--dash-success);
}

.sto-mini-stat-icon.warning {
    background: var(--dash-warning-light);
    color: var(--dash-warning);
}

.sto-mini-stat-content {
    display: flex;
    flex-direction: column;
}

.sto-mini-stat-value {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--dash-text);
    line-height: 1;
    letter-spacing: -0.02em;
}

.sto-mini-stat-label {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
    .sto-mini-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Load STO Button --- */
.sto-load-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--dash-primary);
    color: white;
    border: none;
    border-radius: var(--dash-radius-sm);
    font-size: 0.813rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dash-transition);
}

.sto-load-btn:hover {
    background: var(--dash-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--dash-primary-light);
}

.sto-load-btn:active {
    transform: translateY(0);
}

.sto-load-btn svg {
    width: 16px;
    height: 16px;
}

/* --- Modal --- */
.sto-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sto-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.sto-modal {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sto-modal-overlay.active .sto-modal {
    transform: translateY(0);
}

.sto-modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--dash-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--dash-surface-2);
}

.sto-modal-title-wrap {
    display: flex;
    flex-direction: column;
}

.sto-modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dash-text);
}

.sto-modal-subtitle {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
}

.sto-modal-close {
    background: none;
    border: none;
    color: var(--dash-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: var(--dash-transition);
}

.sto-modal-close:hover {
    background: var(--dash-border);
    color: var(--dash-text);
}

.sto-modal-body {
    padding: 1.5rem;
}

.sto-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.sto-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sto-form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sto-form-group label .required {
    color: var(--dash-danger);
}

.sto-modal-input {
    background: var(--dash-surface-2);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius-sm);
    padding: 0.625rem 0.875rem;
    color: var(--dash-text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: var(--dash-transition);
    width: 100%;
}

.sto-modal-input:focus {
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-primary-light);
    outline: none;
}

.sto-modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--dash-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--dash-surface-2);
}

.sto-btn-secondary {
    padding: 0.625rem 1.25rem;
    background: var(--dash-surface-2);
    border: 1px solid var(--dash-border);
    color: var(--dash-text-secondary);
    border-radius: var(--dash-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dash-transition);
}

.sto-btn-secondary:hover {
    background: var(--dash-border);
    color: var(--dash-text);
}

.sto-btn-primary {
    padding: 0.625rem 1.25rem;
    background: var(--dash-primary);
    border: none;
    color: white;
    border-radius: var(--dash-radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dash-transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sto-btn-primary:hover {
    background: var(--dash-primary-hover);
    box-shadow: 0 4px 12px var(--dash-primary-light);
}

.sto-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Date Range Row */
.sto-date-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Toast */
.sto-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10000;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: 12px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-width: 300px;
    max-width: 90%;
}

.sto-toast.show {
    transform: translateX(-50%) translateY(0);
}

.sto-toast.success {
    border-left: 4px solid var(--dash-success);
}

.sto-toast.error {
    border-left: 4px solid var(--dash-danger);
}

.sto-toast.info {
    border-left: 4px solid var(--dash-info);
}

.sto-toast-icon {
    font-size: 1.25rem;
}

.sto-toast-msg {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dash-text);
}

/* --- Deactivate STO Button --- */
.sto-deactivate-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--dash-danger, #ef4444);
    color: var(--dash-danger, #ef4444);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
}

.sto-deactivate-btn:hover:not(:disabled) {
    background: var(--dash-danger, #ef4444);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.sto-deactivate-btn:active:not(:disabled) {
    transform: translateY(0);
}

.sto-deactivate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--dash-border);
    color: var(--dash-text-muted);
}

/* --- Action Wrap --- */
.sto-action-wrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Toggle Switch */
.sto-virtual-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--dash-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sto-virtual-switch input {
    display: none;
}

.sto-virtual-slider {
    width: 32px;
    height: 16px;
    background-color: var(--dash-border);
    border-radius: 9px;
    position: relative;
    transition: background-color 0.2s ease;
}

.sto-virtual-slider::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
}

.sto-virtual-switch input:checked + .sto-virtual-slider {
    background-color: var(--dash-primary);
}

.sto-virtual-switch input:checked + .sto-virtual-slider::before {
    transform: translateX(16px);
}

.sto-virtual-mapped-indicator {
    font-family: monospace;
    font-size: 0.7rem;
    color: var(--dash-primary);
    background: var(--dash-primary-light);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 2px;
}