/* ============================================
   Tango Search Dashboard — Premium Dark Theme
   ============================================ */

:root {
    /* Color Palette */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-input: rgba(255, 255, 255, 0.05);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #38bdf8;

    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.6);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;

    --font: 'Inter', -apple-system, system-ui, sans-serif;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

/* Utility */
.hidden {
    display: none !important;
}

/* ──── Glass Card ──── */

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* ──── Header ──── */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 14, 26, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

.logo-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #f1f5f9, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.pipeline-mini {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.pipeline-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-input);
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.pipeline-pill .count {
    font-weight: 700;
    color: var(--accent-cyan);
}

.pipeline-pill.total {
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding-left: 12px;
}

.pipeline-loading {
    font-size: 11px;
    color: var(--text-muted);
}

/* ──── Buttons ──── */

.btn {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-accent:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-hover);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-icon {
    font-size: 15px;
}

.badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

/* Spinner for buttons */
.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

/* ──── Main Content ──── */

.main {
    padding: 24px 32px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ──── Search Panel ──── */

.search-panel {
    padding: 24px;
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.search-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 0.6fr;
    gap: 12px;
    align-items: end;
}

.search-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.search-field input,
.search-field select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.search-field input:focus,
.search-field select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-field input::placeholder {
    color: var(--text-muted);
}

.search-field select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.search-field select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.search-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-info {
    margin-left: auto;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ──── Results ──── */

.results-section {
    animation: fadeUp 300ms ease-out;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 4px;
    flex-wrap: wrap;
    gap: 12px;
}

.results-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.results-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 4px 12px;
    transition: var(--transition);
}

.filter-bar:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-icon {
    font-size: 12px;
    opacity: 0.5;
}

.filter-bar input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    width: 160px;
}

.filter-bar input::placeholder {
    color: var(--text-muted);
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}

.table-wrapper {
    overflow-x: auto;
    padding: 0;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

/* Sortable headers */
.results-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
    user-select: none;
}

th.sortable {
    cursor: pointer;
    transition: var(--transition);
}

th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

th.sortable.sort-active {
    color: var(--accent-blue);
}

.sort-arrow {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    opacity: 0;
    transition: var(--transition);
}

th.sortable:hover .sort-arrow {
    opacity: 0.4;
}

th.sortable.sort-active .sort-arrow {
    opacity: 1;
    color: var(--accent-blue);
}

th.sortable.sort-active.sort-asc .sort-arrow::after {
    content: '▲';
}

th.sortable.sort-active.sort-desc .sort-arrow::after {
    content: '▼';
}

th.sortable:not(.sort-active) .sort-arrow::after {
    content: '▲';
}

/* Table rows */
.results-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
}

.results-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.results-table tbody tr.selected {
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--accent-blue);
}

.results-table td {
    padding: 14px 16px;
    vertical-align: top;
    line-height: 1.5;
}

.col-check {
    width: 40px;
    text-align: center;
}

.col-title {
    min-width: 280px;
}

.col-agency {
    min-width: 160px;
}

.col-naics {
    width: 80px;
}

.col-type {
    width: 100px;
}

.col-setaside {
    width: 90px;
}

.col-deadline {
    width: 120px;
}

.col-location {
    width: 120px;
}

.col-link {
    width: 60px;
    text-align: center;
}

.opp-title {
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: block;
    margin-bottom: 2px;
}

.opp-sol {
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

.opp-agency {
    color: var(--text-secondary);
    font-size: 12px;
}

.naics-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    font-weight: 600;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.setaside-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.deadline-text {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.deadline-text.expired {
    color: var(--accent-red);
    text-decoration: line-through;
}

.deadline-text.soon {
    color: var(--accent-amber);
    font-weight: 600;
}

.deadline-days {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.location-text {
    font-size: 12px;
    color: var(--text-muted);
}

.link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.link-btn:hover {
    background: var(--accent-blue);
    color: white;
}

/* Checkbox styling */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* ──── Expandable Detail Row ──── */

.detail-row td {
    padding: 0 !important;
    border-bottom: 1px solid var(--border);
}

.detail-row .detail-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease-out, padding 200ms ease;
    padding: 0 24px;
}

.detail-row.expanded .detail-content {
    max-height: 500px;
    padding: 20px 24px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}

.detail-field {
    font-size: 12px;
}

.detail-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-value {
    color: var(--text-secondary);
    line-height: 1.5;
}

.detail-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-xs);
    margin-top: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ──── Pagination ──── */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 0;
    margin-top: 8px;
}

.page-info {
    font-size: 13px;
    color: var(--text-muted);
    min-width: 120px;
    text-align: center;
}

/* ──── Empty State ──── */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    animation: fadeUp 400ms ease-out;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 14px;
    max-width: 500px;
    margin: 0 auto 24px;
}

.empty-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.tag-btn {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.tag-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.08);
}

/* ──── Loading State ──── */

.loading-state {
    text-align: center;
    padding: 80px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.loading-state p {
    color: var(--text-muted);
    font-size: 14px;
}

/* ──── Modal ──── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 200ms ease-out;
}

.modal {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: scaleIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

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

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

.import-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

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

.import-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.import-item-name {
    font-weight: 500;
    font-size: 13px;
}

.import-item-msg {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.import-item.created .import-item-msg {
    color: var(--accent-green);
}

.import-item.duplicate .import-item-msg {
    color: var(--accent-amber);
}

.import-item.error .import-item-msg {
    color: var(--accent-red);
}

/* ──── Toast ──── */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 300ms ease-out;
    min-width: 240px;
}

.toast.success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.toast.error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast.info {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
}

/* ──── Animations ──── */

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ──── Responsive ──── */

@media (max-width: 1200px) {
    .search-row {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .header {
        padding: 12px 16px;
    }

    .main {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .search-row {
        grid-template-columns: 1fr;
    }

    .header {
        flex-direction: column;
        gap: 12px;
    }

    .header-right {
        width: 100%;
        justify-content: flex-end;
    }

    .pipeline-mini {
        display: none;
    }

    .results-table {
        font-size: 12px;
    }

    .results-table td,
    .results-table th {
        padding: 10px;
    }

    .results-toolbar {
        flex-wrap: wrap;
    }

    .filter-bar input {
        width: 120px;
    }
}