/* 
    Sellnaudit Premium Component Engine 
    Visual Source of Truth: Approved Quotation Registry
*/

/* --- KPI CARDS (sn-card) --- */
.sn-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px; /* Reduced padding */
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.sn-card-accent {
    border-left: 4px solid var(--accent-gold);
}

.sn-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* --- TOOLBAR (sn-toolbar) --- */
.sn-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Right align by default */
    gap: 12px;
    background: transparent;
    padding: 0 4px;
}

.sn-toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: auto; /* Push everything else to the right */
}

.sn-toolbar-right {
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* --- SEARCH (sn-search) --- */
.sn-search {
    position: relative;
    width: 420px;
}

.sn-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 10;
    width: 16px;
    height: 16px;
    opacity: 0.5;
}

.sn-search-input {
    width: 100%;
    height: 42px; /* Exact match with buttons */
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding-left: 42px;
    padding-right: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.sn-search-input:focus {
    outline: none;
    border-color: var(--accent-gold);
}

/* --- BUTTONS --- */
.sn-btn {
    height: 42px; /* Exact match with search */
    padding: 0 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

/* --- TABLE (sn-table) --- */
.sn-table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
    box-shadow: var(--shadow-md);
}

.sn-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.sn-table th {
    background: var(--bg-surface-2);
    padding: 16px 20px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.sn-table td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.sn-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

.sn-table tbody tr:hover {
    background: var(--bg-primary) !important;
}

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

/* --- STATUS BADGES (sn-status) --- */
.sn-status {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.sn-status-gray { background: rgba(107, 114, 128, 0.1); color: #6B7280; }
.sn-status-blue { background: rgba(37, 99, 235, 0.1); color: var(--accent-blue); }
.sn-status-amber { background: rgba(217, 119, 6, 0.1); color: var(--accent-amber); }
.sn-status-green { background: rgba(22, 163, 74, 0.1); color: var(--accent-green); }
.sn-status-red { background: rgba(220, 38, 38, 0.1); color: var(--accent-red); }

/* --- VALUE PILLS --- */
.sn-value-pill {
    background: var(--accent-gold-soft);
    color: var(--accent-gold);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    display: inline-block;
}

.sn-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.sn-btn-primary {
    background: var(--accent-gold);
    color: #000 !important;
    font-weight: 700;
    transition: all 0.2s ease;
}

.sn-btn-primary:hover, 
.sn-btn-primary:focus,
.sn-btn-primary:active {
    background: #d4a017; /* Slightly darker gold */
    color: #000 !important;
    box-shadow: 0 4px 12px rgba(212, 160, 23, 0.3);
    transform: translateY(-1px);
}

.sn-btn-primary:hover {
    background: #D4A83F;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 168, 63, 0.3);
}

.sn-btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.sn-btn-secondary:hover {
    border-color: var(--accent-gold);
}

/* --- SELLNAUDIT FORMS & UNIFIED INPUTS --- */
.sn-workspace {
    padding: 1rem;
}

.sn-master-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

@media (max-width: 1200px) {
    .sn-master-layout {
        grid-template-columns: 1fr;
    }
}

.sn-input-system {
    height: 32px;
    width: 100%;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-primary);
    color: var(--text-primary) !important;
    font-size: 0.8rem;
    transition: var(--transition);
    outline: none;
}

.sn-input-system:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px var(--accent-gold-soft);
    background: var(--bg-surface);
}

.sn-input-system.bg-muted {
    background-color: rgba(0, 0, 0, 0.05);
    cursor: not-allowed;
    border-style: dashed;
}

[data-bs-theme="dark"] .sn-input-system.bg-muted {
    background-color: rgba(255, 255, 255, 0.05);
}

.sn-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
    display: block;
}

.sn-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.sn-card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sn-card-body {
    padding: 1rem;
}

.sn-grid-table thead th {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
}

.sn-grid-table tbody td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    height: 42px;
    color: var(--text-primary);
}

.sn-badge-info {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.65rem;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.sn-analysis-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sn-analysis-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 4px;
}

.sn-analysis-row .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sn-analysis-row .value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-gold) !important;
}

.sn-analysis-row .value.text-primary {
    color: var(--accent-blue) !important;
}
.sn-analysis-row .value.text-danger {
    color: var(--accent-red) !important;
}

.sn-grand-total-box {
    background: linear-gradient(135deg, #0b1020 0%, #162033 100%);
    padding: 1.2rem;
    border-radius: 10px;
    border: 1px solid var(--accent-gold);
    text-align: right;
    box-shadow: var(--shadow-md);
}

[data-bs-theme="light"] .sn-grand-total-box {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.sn-grand-total-box .label {
    color: var(--text-secondary);
    font-size: 0.6rem;
    margin: 0;
}

.sn-grand-total-box .amount {
    color: var(--accent-gold);
    font-size: 1.6rem;
    font-weight: 800;
}

.sn-btn-gold {
    background: var(--accent-gold);
    color: #000 !important;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    cursor: pointer;
    padding: 6px 16px;
}

.sn-btn-gold:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-gold-soft);
}

.shadow-glow {
    box-shadow: 0 0 15px var(--accent-gold-soft);
}

.btn-delete {
    background: none;
    border: none;
    color: var(--accent-red);
    opacity: 0.4;
    transition: var(--transition);
    padding: 4px;
    cursor: pointer;
}

.btn-delete:hover {
    opacity: 1;
    transform: scale(1.1);
}

.btn-delete i {
    width: 16px;
}

/* SELECT2 THEME FIXES */
.select2-container--bootstrap-5 .select2-selection {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    height: 32px !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--bootstrap-5 .select2-selection__rendered {
    color: var(--text-primary) !important;
    font-size: 0.8rem !important;
}

.select2-dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
}

.select2-results__option {
    color: var(--text-primary) !important;
    font-size: 0.8rem !important;
}

.select2-results__option--highlighted[aria-selected] {
    background: var(--accent-gold) !important;
    color: #000 !important;
}

.select2-search__field {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
}

/* TOMSELECT THEME FIXES */
.ts-wrapper.form-control, 
.ts-wrapper.form-select, 
.ts-control {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
    font-size: 0.8rem !important;
    box-shadow: none !important;
}

/* Fix input field inside tom select */
.ts-wrapper .ts-control input {
    color: var(--text-primary) !important;
    font-size: 0.8rem !important;
    background: transparent !important;
}

/* Focus state */
.ts-wrapper.focus .ts-control {
    border-color: var(--accent-gold) !important;
    box-shadow: 0 0 0 3px var(--accent-gold-soft) !important;
    background: var(--bg-surface) !important;
}

/* Dropdown styling */
.ts-dropdown {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
}

/* Options */
.ts-dropdown .option {
    color: var(--text-primary) !important;
    font-size: 0.8rem !important;
    padding: 8px 12px !important;
}

/* Active option state */
.ts-dropdown .active,
.ts-dropdown .option.active {
    background: var(--accent-gold-soft) !important;
    color: var(--accent-gold) !important;
}

/* Multi-select items (pills) */
.ts-control .item {
    background: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px !important;
}

/* Clear button and other elements */
.ts-wrapper .clear-button {
    color: var(--text-secondary) !important;
}

/* Handle option subtext/details in custom templates (e.g. products) */
.ts-dropdown .text-body {
    color: var(--text-primary) !important;
}
.ts-dropdown .text-secondary {
    color: var(--text-secondary) !important;
}
.ts-dropdown .text-success {
    color: var(--accent-green) !important;
}

kbd {
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.6rem;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
}

/* --- DETAIL & SHOW VIEWS --- */
.glass-card,
.premium-glass-card {
    background: rgba(22, 32, 51, 0.65) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(37, 49, 73, 0.6) !important;
    border-radius: 16px !important;
    transition: var(--transition);
}

[data-bs-theme="light"] .glass-card,
[data-bs-theme="light"] .premium-glass-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid var(--border) !important;
}

.glass-card:hover,
.premium-glass-card:hover {
    border-color: rgba(212, 175, 55, 0.3) !important;
    box-shadow: var(--shadow-lg) !important;
}

.btn-golden-grad {
    background: linear-gradient(135deg, #d4af37 0%, #b8860b 100%) !important;
    border: none !important;
    color: #121212 !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px !important;
    transition: var(--transition) !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px !important;
    border-radius: 8px !important;
}

.btn-golden-grad:hover {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%) !important;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4) !important;
    transform: translateY(-2px) !important;
    color: #000 !important;
}

.btn-purple-grad {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    transition: var(--transition) !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px !important;
    border-radius: 8px !important;
}

.btn-purple-grad:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%) !important;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4) !important;
    transform: translateY(-2px) !important;
    color: #ffffff !important;
}

.custom-form-control {
    background-color: rgba(22, 32, 51, 0.5) !important;
    border: 1px solid rgba(37, 49, 73, 0.6) !important;
    color: var(--text-primary) !important;
    border-radius: 10px !important;
    transition: var(--transition) !important;
}

[data-bs-theme="light"] .custom-form-control {
    background-color: #ffffff !important;
    border: 1px solid var(--border) !important;
}

.custom-form-control:focus {
    background-color: rgba(22, 32, 51, 0.8) !important;
    border-color: var(--accent-gold) !important;
    box-shadow: 0 0 8px var(--accent-gold-soft) !important;
}

.custom-table th {
    background-color: rgba(22, 32, 51, 0.45) !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase;
    font-size: 0.65rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.1em !important;
    padding: 14px 18px !important;
}

[data-bs-theme="light"] .custom-table th {
    background-color: #f8f9fa !important;
}

.custom-table tbody tr {
    background-color: transparent !important;
}

.custom-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

[data-bs-theme="light"] .custom-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.01) !important;
}

.custom-table td {
    background-color: transparent !important;
    padding: 14px 18px !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid rgba(37, 49, 73, 0.3) !important;
}

[data-bs-theme="light"] .custom-table td {
    border-bottom: 1px solid var(--border) !important;
}

.text-dark-white {
    color: var(--text-primary) !important;
}

.text-dark-muted {
    color: var(--text-secondary) !important;
}

.border-dark-muted {
    border-color: var(--border) !important;
}

.card-header h6 {
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
}

/* Premium Status Badges */
.sn-status-badge,
.premium-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px !important;
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    border-radius: 8px !important;
    border-width: 1px !important;
    border-style: solid !important;
    letter-spacing: 0.05em !important;
    line-height: 1 !important;
}

.sn-status-badge.posted,
.sn-status-badge.paid,
.premium-status-badge.status-success,
.premium-status-badge.status-active,
.premium-status-badge.posted,
.premium-status-badge.paid {
    background-color: rgba(34, 197, 94, 0.15) !important;
    color: #22c55e !important;
    border-color: rgba(34, 197, 94, 0.3) !important;
}

.sn-status-badge.draft,
.sn-status-badge.unpaid,
.premium-status-badge.status-warning,
.premium-status-badge.status-draft,
.premium-status-badge.draft,
.premium-status-badge.unpaid {
    background-color: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.sn-status-badge.partially_paid,
.sn-status-badge.warning,
.sn-status-badge.sent,
.premium-status-badge.status-pending,
.premium-status-badge.warning,
.premium-status-badge.sent {
    background-color: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
    border-color: rgba(245, 158, 11, 0.3) !important;
}

.sn-status-badge.secondary,
.premium-status-badge.secondary {
    background-color: rgba(148, 163, 184, 0.15) !important;
    color: #94a3b8 !important;
    border-color: rgba(148, 163, 184, 0.3) !important;
}

/* Subtle Card Backgrounds */
.sn-card-subtle {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--border) !important;
}

[data-bs-theme="light"] .sn-card-subtle {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

/* Timeline */
.timeline-container {
    position: relative;
}

.timeline-item {
    position: relative;
    padding-left: 2.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-icon {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    transform: translateX(-5px);
}

/* Icon Helper Classes */
.sn-icon {
    width: 16px !important;
    height: 16px !important;
    display: inline-block;
    vertical-align: middle;
}
.sn-icon-sm {
    width: 12px !important;
    height: 12px !important;
    display: inline-block;
    vertical-align: middle;
}
.sn-icon-lg {
    width: 20px !important;
    height: 20px !important;
    display: inline-block;
    vertical-align: middle;
}
.sn-icon-xl {
    width: 32px !important;
    height: 32px !important;
    display: inline-block;
    vertical-align: middle;
}

/* Sidebar Nav Arrow Rotation Fixes */
.rotate-90 {
    transform: rotate(90deg) !important;
}
.sn-menu-item[aria-expanded="true"] .nav-arrow,
.sn-menu-item-active .nav-arrow {
    transform: rotate(90deg) !important;
    opacity: 1 !important;
}

/* Premium Glass Inputs */
.premium-glass-input {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    transition: var(--transition);
}

[data-bs-theme="light"] .premium-glass-input {
    background-color: rgba(0, 0, 0, 0.03) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

.premium-glass-input:focus {
    border-color: var(--accent-gold) !important;
    background-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 0 3px var(--accent-gold-soft) !important;
}

[data-bs-theme="light"] .premium-glass-input:focus {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

.premium-glass-input[readonly],
.premium-glass-input:disabled {
    background-color: rgba(0, 0, 0, 0.15) !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

[data-bs-theme="light"] .premium-glass-input[readonly],
[data-bs-theme="light"] .premium-glass-input:disabled {
    background-color: rgba(0, 0, 0, 0.07) !important;
}

/* --- PREMIUM WINDOWS / MODALS UX OVERRIDES --- */
.modal-content {
    background-color: var(--bg-surface) !important;
    border: 1.5px solid rgba(212, 160, 23, 0.25) !important; /* Subtle Gold border for dark theme identification */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 20px rgba(255, 255, 255, 0.04) !important;
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
}

[data-bs-theme="light"] .modal-content {
    border: 1.5px solid rgba(0, 0, 0, 0.15) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1) !important;
}

/* Backdrop glassmorphism blur for better layout focus */
.modal-backdrop.show {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    background-color: rgba(6, 10, 20, 0.75) !important;
    opacity: 1 !important;
}

/* Clean header divider line */
.modal-header {
    border-bottom: 1px solid var(--border) !important;
    background-color: rgba(255, 255, 255, 0.02);
    padding: 1rem 1.5rem !important;
}

[data-bs-theme="light"] .modal-header {
    background-color: rgba(0, 0, 0, 0.02);
}

.modal-footer {
    border-top: 1px solid var(--border) !important;
    padding: 1rem 1.5rem !important;
}


