/* ========================================
   WineDux Admin — typography & brand
   ======================================== */

:root {
    --wd-navy: #051e57;
    --wd-primary: #0668b1;
    --wd-primary-dark: #055a9a;
    --wd-primary-light: #e8f2fa;
    --wd-text: #0f172a;
    --wd-text-muted: #64748b;
    --wd-border: rgba(5, 30, 87, 0.1);
    --wd-page-bg: #f1f5f9;
    --wd-radius: 10px;
    --wd-shadow-sidebar: 2px 0 24px rgba(5, 30, 87, 0.06);
}

/* Bootstrap 5 theme tokens */
:root,
[data-bs-theme="light"] {
    --bs-primary: #0668b1;
    --bs-primary-rgb: 6, 104, 177;
    --bs-link-color: #0668b1;
    --bs-link-hover-color: #051e57;
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--wd-text);
    --bs-border-color: var(--wd-border);
    --bs-heading-color: var(--wd-navy);
}

body {
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.011em;
    line-height: 1.55;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: "Oswald", "Inter", system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: none;
}

/* Sidebar — pure white + logo */
.sidebar {
    min-width: 260px;
    max-width: 260px;
    min-height: 100vh;
    background: #ffffff;
    color: var(--wd-text);
    transition: margin 0.25s ease-out;
    border-right: 1px solid var(--wd-border) !important;
    box-shadow: var(--wd-shadow-sidebar);
}

.sidebar.toggled {
    margin-left: -260px;
}

.sidebar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--wd-border);
    padding: 12px 14px 14px;
}

.sidebar-logo-link {
    display: block;
    line-height: 0;
    text-decoration: none;
    text-align: center;
}

.sidebar-logo-link:hover {
    opacity: 0.92;
}

.sidebar-logo-img {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
    max-height: 56px;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
    object-position: center center;
}

.sidebar.d-flex.flex-column {
    min-height: 100vh;
}

.sidebar-nav.flex-grow-1 {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 10px 16px;
}

.sidebar-footer {
    border-top: 1px solid var(--wd-border);
    background: #fff;
    padding: 10px 10px 14px;
}

.sidebar-logout-link {
    display: flex;
    align-items: center;
    border-radius: var(--wd-radius);
    margin-bottom: 0;
}

.sidebar-logout-link i {
    width: 20px;
    margin-right: 0.5rem;
    text-align: center;
}

/* Legacy collapsible section */
.sidebar-legacy-toggle {
    cursor: pointer;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--wd-radius);
    margin-bottom: 2px;
    letter-spacing: -0.01em;
    transition: color 0.18s, background 0.18s;
}

.sidebar-legacy-toggle:hover {
    color: var(--wd-navy);
    background: rgba(5, 30, 87, 0.045);
}

.sidebar-legacy-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(6, 104, 177, 0.35);
}

.sidebar-legacy-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    opacity: 0.85;
}

.sidebar-legacy-toggle[aria-expanded="true"] .sidebar-legacy-chevron {
    transform: rotate(90deg);
}

.sidebar-legacy-panel {
    padding-bottom: 4px;
}

.sidebar-legacy-subheader {
    padding-left: 1.75rem;
    padding-top: 0.65rem;
}

.sidebar-legacy-link {
    padding-left: 1.75rem !important;
    font-size: 0.8125rem;
}

.sidebar-legacy-link i {
    width: 18px;
    margin-right: 0.45rem;
}

.sidebar-nav .nav-header {
    padding: 0.85rem 1rem 0.35rem;
    font-family: "Oswald", "Inter", sans-serif;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--wd-text-muted);
    font-weight: 600;
}

.sidebar-nav .nav-link {
    color: #475569;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--wd-radius);
    border-left: 3px solid transparent;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
    transition: color 0.18s, background 0.18s, border-color 0.18s;
}

.sidebar-nav .nav-link:hover {
    color: var(--wd-navy);
    background: rgba(5, 30, 87, 0.045);
    border-left-color: transparent;
}

.sidebar-nav .nav-link.active {
    color: var(--wd-navy);
    background: var(--wd-primary-light);
    border-left-color: var(--wd-primary);
}

.sidebar-nav .nav-link i {
    width: 20px;
    margin-right: 0.5rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar-nav .nav-link.active i {
    color: var(--wd-primary);
    opacity: 1;
}

.sidebar-nav .nav-link.text-danger {
    color: rgba(220, 38, 38, 0.85) !important;
}

.sidebar-nav .nav-link.text-danger:hover {
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.06);
}

/* Main content */
#page-content-wrapper {
    min-height: 100vh;
    background: var(--wd-page-bg);
}

#page-content-wrapper > .navbar {
    background: rgba(255, 255, 255, 0.92) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: var(--wd-border) !important;
    box-shadow: 0 1px 2px rgba(5, 30, 87, 0.04);
}

#page-content-wrapper .breadcrumb {
    font-size: 0.875rem;
    font-weight: 500;
}

#page-content-wrapper .breadcrumb-item a {
    color: var(--wd-primary);
    text-decoration: none;
}

#page-content-wrapper .breadcrumb-item a:hover {
    text-decoration: underline;
    color: var(--wd-navy);
}

#page-content-wrapper .breadcrumb-item.active {
    color: var(--wd-navy);
    font-weight: 600;
}

#sidebarToggle {
    border-color: var(--wd-border);
    color: var(--wd-navy);
    border-radius: var(--wd-radius);
}

#sidebarToggle:hover {
    background: rgba(5, 30, 87, 0.05);
    border-color: rgba(5, 30, 87, 0.12);
    color: var(--wd-navy);
}

/* Cards & stats */
.stat-card {
    border: 1px solid var(--wd-border);
    border-radius: 0.875rem;
    box-shadow: 0 1px 2px rgba(5, 30, 87, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(5, 30, 87, 0.08);
    border-color: rgba(6, 104, 177, 0.18);
}

.stat-card .card-body {
    padding: 1.25rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
    color: var(--wd-navy);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--wd-text-muted);
    margin-top: 0.25rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.card {
    border-color: var(--wd-border);
    border-radius: 0.875rem;
}

.card-header {
    font-family: "Oswald", "Inter", sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--wd-navy);
    background: linear-gradient(180deg, #fafbfc 0%, #fff 100%);
    border-bottom-color: var(--wd-border);
}

/* Buttons — tighter, on-brand */
.btn {
    font-weight: 500;
    letter-spacing: -0.01em;
    border-radius: var(--wd-radius);
}

.btn-primary {
    background: var(--wd-primary);
    border-color: var(--wd-primary);
    box-shadow: 0 1px 2px rgba(5, 30, 87, 0.08);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--wd-primary-dark);
    border-color: var(--wd-primary-dark);
}

.btn-primary:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(6, 104, 177, 0.35);
}

.btn-outline-primary {
    color: var(--wd-primary);
    border-color: rgba(6, 104, 177, 0.35);
}

.btn-outline-primary:hover {
    background: var(--wd-primary);
    border-color: var(--wd-primary);
    color: #fff;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--wd-primary);
    box-shadow: 0 0 0 0.2rem rgba(6, 104, 177, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--wd-text);
}

/* Login / register */
body.login-page-body {
    min-height: 100vh;
    background: linear-gradient(165deg, #e8f2fa 0%, #f1f5f9 45%, #eef2f7 100%);
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--wd-border);
    border-radius: 1rem;
    box-shadow: 0 12px 48px rgba(5, 30, 87, 0.1);
}

.login-card .card-body {
    padding: 2.5rem;
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo-link {
    display: inline-block;
    line-height: 0;
    margin-bottom: 1rem;
}

.login-logo-link:hover {
    opacity: 0.94;
}

.login-logo-img {
    max-width: 240px;
    width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: contain;
}

.login-tagline {
    font-family: "Oswald", "Inter", sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--wd-text-muted);
    margin: 0;
}

.login-card .input-group-text {
    background: #f8fafc;
    border-color: var(--wd-border);
    color: var(--wd-text-muted);
}

.login-card .form-control {
    border-color: var(--wd-border);
}

/* DataTables */
.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--wd-radius);
    border-color: var(--wd-border);
}

table.dataTable thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--wd-text-muted);
    font-weight: 600;
    background: #fafbfc;
}

table.dataTable tbody tr:hover {
    background: rgba(6, 104, 177, 0.04);
}

/* Action buttons in tables */
.btn-action {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

/* Responsive sidebar */
@media (max-width: 768px) {
    .sidebar {
        margin-left: -260px;
        position: fixed;
        z-index: 1050;
    }

    .sidebar.toggled {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(5, 30, 87, 0.35);
        z-index: 1040;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

/* Utility */
.text-truncate-200 {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-index {
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========================================
   Scraped AI matching page
   ======================================== */

.sai-progress {
    font-size: 0.8rem;
    padding: 0.4em 0.9em;
}

.sai-card {
    border-color: var(--wd-border);
    border-radius: 0.875rem;
}

.sai-wine-text {
    font-family: "Oswald", "Inter", sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--wd-navy);
    line-height: 1.3;
    word-break: break-word;
}

.sai-ai-fields {
    background: #f8fafc;
    border: 1px solid var(--wd-border);
    border-radius: var(--wd-radius);
    padding: 0.875rem 1rem;
}

.sai-field-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--wd-text-muted);
    margin-bottom: 2px;
}

.sai-field-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--wd-text);
    min-height: 1.4em;
}

/* Suggestion buttons */
.sai-suggestion-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--wd-border);
    border-radius: var(--wd-radius);
    background: #fff;
    color: var(--wd-text);
    font-size: 0.875rem;
    text-align: left;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    cursor: pointer;
    width: 100%;
}

.sai-suggestion-btn:hover {
    border-color: var(--wd-primary);
    background: var(--wd-primary-light);
    box-shadow: 0 2px 8px rgba(6, 104, 177, 0.1);
}

.sai-sugg-num {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--wd-primary-light);
    color: var(--wd-primary);
    font-weight: 700;
    font-size: 0.8rem;
}

.sai-suggestion-btn:hover .sai-sugg-num {
    background: var(--wd-primary);
    color: #fff;
}

.sai-sugg-body {
    flex: 1;
    min-width: 0;
}

.sai-sugg-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--wd-text-muted);
    margin-top: 2px;
}

/* Typeahead wine search (jump to specific scraped wine) */
.sai-typeahead-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: #fff;
    border: 1px solid var(--wd-border);
    border-radius: var(--wd-radius);
    box-shadow: 0 8px 24px rgba(5, 30, 87, 0.12);
    max-height: 360px;
    overflow-y: auto;
}

.sai-typeahead-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--wd-border);
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--wd-text);
    background: #fff;
    width: 100%;
    text-align: left;
    border-left: none;
    border-right: none;
    border-top: none;
}

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

.sai-typeahead-item:hover,
.sai-typeahead-item.active {
    background: var(--wd-primary-light);
}

.sai-typeahead-wine {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.sai-typeahead-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--wd-primary);
    background: var(--wd-primary-light);
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.sai-typeahead-empty {
    padding: 10px 12px;
    color: var(--wd-text-muted);
    font-size: 0.8125rem;
}

/* Search results in modal */
.sai-search-results {
    max-height: 400px;
    overflow-y: auto;
}

.sai-search-results .list-group-item {
    font-size: 0.875rem;
    cursor: pointer;
}

.sai-search-results .list-group-item:hover {
    background: var(--wd-primary-light);
}

/* Toast */
.sai-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 22px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--wd-navy);
    color: #fff;
    box-shadow: 0 8px 28px rgba(5, 30, 87, 0.18);
    z-index: 9999;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s, transform 0.25s;
    max-width: 420px;
    pointer-events: none;
}

.sai-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.sai-toast-error {
    background: #991b1b;
}

/* History log */
.sai-history-list {
    max-height: 320px;
    overflow-y: auto;
}

.sai-history-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--wd-border);
    font-size: 0.8125rem;
}

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

.sai-history-main {
    flex: 1;
    min-width: 0;
}

.sai-history-meta {
    color: var(--wd-text-muted);
    font-size: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.sai-history-dot {
    opacity: 0.4;
}

.sai-history-detail {
    line-height: 1.4;
    word-break: break-word;
}

.sai-history-undone {
    opacity: 0.5;
}

.sai-history-undone .sai-history-detail {
    text-decoration: line-through;
}

.sai-history-badge {
    flex-shrink: 0;
    align-self: center;
    font-size: 0.7rem;
}

.sai-modal-wine-ref {
    font-weight: 600;
    color: var(--wd-navy);
    margin-top: 2px;
    word-break: break-word;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    padding: 4px 0;
    border-radius: 4px;
}

.sai-modal-wine-ref::selection {
    background: rgba(6, 104, 177, 0.22);
}

.sai-undo-btn {
    flex-shrink: 0;
    align-self: center;
    font-size: 0.75rem;
    padding: 3px 10px;
}
