@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --app-primary: #15803d;
    --app-primary-dark: #166534;
    --app-primary-rgb: 21, 128, 61;
    --app-sidebar: #111827;
    --app-sidebar-hover: #1f2937;
    --app-sidebar-muted: #9ca3af;
    --app-sidebar-active: rgba(21, 128, 61, 0.15);
    --app-background: #f3f4f6;
    --app-card: #ffffff;
    --app-border: #e5e7eb;
    --app-text: #111827;
    --app-muted: #6b7280;
    --app-danger: #dc2626;
    --app-warning: #d97706;
    --app-success: #16a34a;
    --app-info: #0284c7;
    --app-radius: 0.625rem;
    --app-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
    --app-sidebar-width: 260px;
    --app-sidebar-collapsed-width: 72px;
    --app-topbar-height: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body.admin-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--app-background);
    color: var(--app-text);
    min-height: 100vh;
}

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--app-sidebar-width);
    height: 100vh;
    background: var(--app-sidebar);
    color: #fff;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}

.admin-sidebar.collapsed {
    width: var(--app-sidebar-collapsed-width);
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    min-height: var(--app-topbar-height);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.admin-sidebar-brand:hover {
    color: #fff;
}

.admin-sidebar-brand .brand-icon {
    width: 36px;
    height: 36px;
    background: var(--app-primary);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
}

.admin-sidebar-brand .brand-text {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
}

.admin-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
}

.admin-sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.admin-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.nav-section-label {
    padding: 0.75rem 1.25rem 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--app-sidebar-muted);
    white-space: nowrap;
}

.admin-sidebar.collapsed .nav-section-label,
.admin-sidebar.collapsed .brand-text,
.admin-sidebar.collapsed .nav-link-text,
.admin-sidebar.collapsed .nav-chevron {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.admin-nav,
.admin-nav-sub {
    list-style: none;
    margin: 0;
    padding: 0;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    margin: 0.125rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--app-sidebar-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.admin-nav-link:hover {
    background: var(--app-sidebar-hover);
    color: #fff;
}

.admin-nav-link.active {
    background: var(--app-sidebar-active);
    color: #fff;
}

.admin-nav-link.active .nav-link-icon {
    color: var(--app-primary);
}

.admin-nav-link .nav-link-icon {
    font-size: 1.125rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

/* Parent items that open a sub-list */
.admin-nav-toggle {
    width: calc(100% - 1.5rem);
    background: none;
    border: 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}

.admin-nav-toggle.active-parent {
    color: #fff;
}

.admin-nav-toggle.active-parent .nav-link-icon {
    color: var(--app-primary);
}

.nav-chevron {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.admin-nav-item.open > .admin-nav-toggle .nav-chevron {
    transform: rotate(180deg);
}

/* Sub-lists animate open using a max-height transition */
.admin-nav-sub {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.admin-nav-item.open > .admin-nav-sub {
    max-height: 30rem;
}

.admin-nav-sublink {
    display: block;
    position: relative;
    padding: 0.4375rem 1.25rem 0.4375rem 3.25rem;
    margin: 0.0625rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--app-sidebar-muted);
    text-decoration: none;
    font-size: 0.8125rem;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.admin-nav-sublink::before {
    content: '';
    position: absolute;
    left: 1.875rem;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
}

.admin-nav-sublink:hover {
    background: var(--app-sidebar-hover);
    color: #fff;
}

.admin-nav-sublink.active {
    background: var(--app-sidebar-active);
    color: #fff;
}

.admin-nav-sublink.active::before {
    background: var(--app-primary);
    opacity: 1;
}

/* Collapsed rail shows icons only, so sub-lists stay hidden */
.admin-sidebar.collapsed .admin-nav-sub {
    display: none;
}

.admin-sidebar.collapsed .admin-nav-link {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Main content */
.admin-main {
    flex: 1;
    margin-left: var(--app-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

.admin-sidebar.collapsed ~ .admin-main,
body.sidebar-collapsed .admin-main {
    margin-left: var(--app-sidebar-collapsed-width);
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: var(--app-card);
    border-bottom: 1px solid var(--app-border);
    min-height: var(--app-topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.admin-content {
    flex: 1;
    padding: 1.5rem;
}

.admin-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--app-border);
    background: var(--app-card);
    color: var(--app-muted);
    font-size: 0.8125rem;
}

/* Cards & stats */
.admin-card {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
}

.stat-card {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 1.25rem;
    box-shadow: var(--app-shadow);
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

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

.stat-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--app-text);
}

.stat-card-label {
    font-size: 0.8125rem;
    color: var(--app-muted);
    font-weight: 500;
}

/* Page header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--app-text);
    margin: 0;
}

.page-header-subtitle {
    color: var(--app-muted);
    font-size: 0.9375rem;
    margin: 0.25rem 0 0;
}

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

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

.status-badge-success { background: #dcfce7; color: #166534; }
.status-badge-warning { background: #fef3c7; color: #92400e; }
.status-badge-danger { background: #fee2e2; color: #991b1b; }
.status-badge-info { background: #e0f2fe; color: #075985; }
.status-badge-secondary { background: #f3f4f6; color: #374151; }
.status-badge-primary { background: #dcfce7; color: var(--app-primary-dark); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: var(--app-background);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--app-muted);
}

.empty-state-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--app-muted);
    max-width: 400px;
    margin: 0 auto 1.25rem;
    font-size: 0.9375rem;
}

/* Filter bar */
.filter-bar {
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

/* Tables */
.admin-table {
    margin-bottom: 0;
}

.admin-table thead th {
    background: var(--app-background);
    border-bottom: 1px solid var(--app-border);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-muted);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.admin-table tbody td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--app-border);
    font-size: 0.875rem;
}

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

.admin-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.015);
}

/* Forms */
.btn-primary {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

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

.btn-outline-primary {
    color: var(--app-primary);
    border-color: var(--app-primary);
}

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

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.15);
}

.form-label.required::after {
    content: ' *';
    color: var(--app-danger);
}

.btn-loading {
    position: relative;
    pointer-events: none;
}

.btn-loading .btn-text {
    visibility: hidden;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin: -0.5rem 0 0 -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: admin-spin 0.6s linear infinite;
}

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

/* Image preview card */
.image-preview-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    overflow: hidden;
    background: var(--app-card);
}

.image-preview-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--app-background);
}

.image-preview-card-body {
    padding: 0.75rem;
}

/* Product grid */
.product-grid-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    overflow: hidden;
    background: var(--app-card);
    transition: box-shadow 0.15s;
}

.product-grid-card:hover {
    box-shadow: var(--app-shadow);
}

.product-grid-card .product-thumb {
    aspect-ratio: 1;
    object-fit: cover;
    width: 100%;
    background: var(--app-background);
}

/* Auth layout */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
}

.auth-brand-panel {
    flex: 1;
    background: linear-gradient(135deg, var(--app-sidebar) 0%, #1f2937 50%, var(--app-primary-dark) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.auth-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-brand-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.auth-brand-logo {
    width: 56px;
    height: 56px;
    background: var(--app-primary);
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
}

.auth-brand-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.auth-brand-tagline {
    font-size: 1.0625rem;
    opacity: 0.85;
    line-height: 1.6;
}

.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--app-background);
    max-width: 560px;
}

.auth-form-card {
    width: 100%;
    max-width: 420px;
    background: var(--app-card);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 2rem;
    box-shadow: var(--app-shadow);
}

.auth-form-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-form-subtitle {
    color: var(--app-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

/* Registration wizard progress */
.auth-wizard-steps {
    font-size: 0.8125rem;
}

.auth-wizard-bullet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--app-border, #e5e7eb);
    color: var(--app-muted, #6b7280);
    font-weight: 600;
    flex-shrink: 0;
}

.auth-wizard-steps .is-current .auth-wizard-bullet,
.auth-wizard-steps .is-complete .auth-wizard-bullet {
    background: var(--app-primary, #4f46e5);
    color: #fff;
}

.auth-wizard-steps .is-current .auth-wizard-label {
    color: var(--app-primary, #4f46e5);
    font-weight: 600;
}

.auth-wizard-label {
    color: var(--app-muted, #6b7280);
    white-space: nowrap;
}

.auth-wizard-divider {
    height: 1px;
    background: var(--app-border, #e5e7eb);
    min-width: 1.5rem;
}

.password-toggle-wrap {
    position: relative;
}

.password-toggle-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--app-muted);
    padding: 0;
    cursor: pointer;
    line-height: 1;
}

.password-toggle-wrap .form-control {
    padding-right: 2.5rem;
}

/* Store switcher */
.store-switcher-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--app-border);
    border-radius: 0.5rem;
    background: var(--app-card);
    font-size: 0.875rem;
    font-weight: 500;
    max-width: 220px;
}

.store-switcher-btn .store-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Breadcrumb */
.admin-breadcrumb {
    font-size: 0.8125rem;
    margin-bottom: 0;
}

.admin-breadcrumb .breadcrumb-item a {
    color: var(--app-muted);
    text-decoration: none;
}

.admin-breadcrumb .breadcrumb-item.active {
    color: var(--app-text);
}

/* Flash messages */
.flash-messages .alert {
    border-radius: var(--app-radius);
    border: none;
    box-shadow: var(--app-shadow);
}

/* Sidebar overlay mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

/* Responsive */
@media (max-width: 991.98px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.mobile-open {
        transform: translateX(0);
    }

    .admin-main {
        margin-left: 0 !important;
    }

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

    .auth-brand-panel {
        display: none;
    }

    .auth-form-panel {
        max-width: none;
    }
}

@media (min-width: 992px) {
    .auth-form-panel {
        min-width: 480px;
    }
}

/* ------------------------------------------------------------------ Product hunting */

.hunt-preset {
    display: block;
    position: relative;
    padding: 1rem 1rem 1rem 2.5rem;
    border: 1px solid var(--app-border, #e5e7eb);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.hunt-preset:hover {
    border-color: var(--app-primary, #4f46e5);
    background: rgba(79, 70, 229, 0.03);
}

.hunt-preset .form-check-input {
    position: absolute;
    top: 1.15rem;
    left: 1rem;
    margin: 0;
}

.hunt-preset:has(.form-check-input:checked) {
    border-color: var(--app-primary, #4f46e5);
    background: rgba(79, 70, 229, 0.06);
    box-shadow: 0 0 0 1px var(--app-primary, #4f46e5);
}

.hunt-preset-title {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.hunt-preset-text {
    display: block;
    font-size: 0.8125rem;
    color: var(--app-muted, #6b7280);
    line-height: 1.4;
}

.hunt-result {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.15s ease;
}

.hunt-result:hover {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.hunt-result-muted {
    opacity: 0.6;
}

.hunt-result-media {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 190px;
    background: #f8fafc;
    border-bottom: 1px solid var(--app-border, #e5e7eb);
}

.hunt-result-media img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.hunt-result-check {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: #fff;
    border-radius: 0.375rem;
    padding: 0.125rem 0.375rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
}

.hunt-result-score {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    min-width: 2rem;
}

.hunt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}

.hunt-chip-pass {
    background: rgba(22, 163, 74, 0.1);
    color: #15803d;
}

.hunt-chip-fail {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
}

/* Numbered markers for the two-step fetch-then-generate flow. */
.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
}
