/* =========================================================================
   ResaleTrack Pro - custom styling
   Loaded after Bootstrap 5. Uses CSS custom properties so the admin theme
   color picker (Settings > General) can override brand colors at runtime.
   ========================================================================= */

:root {
    --rtp-primary: #1e3a5f;
    --rtp-primary-dark: #142943;
    --rtp-accent: #0d9488;
    --rtp-accent-dark: #0b7a70;
    --rtp-bg: #f4f6f9;
    --rtp-surface: #ffffff;
    --rtp-border: #e2e8f0;
    --rtp-text: #1f2937;
    --rtp-text-muted: #64748b;
    --rtp-success: #15803d;
    --rtp-warning: #b45309;
    --rtp-danger: #b91c1c;
    --rtp-sidebar-width: 260px;
}

body {
    background-color: var(--rtp-bg);
    color: var(--rtp-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--rtp-accent-dark); }
a:hover { color: var(--rtp-primary); }

/* ---------- Buttons ---------- */
.btn-primary {
    background-color: var(--rtp-primary);
    border-color: var(--rtp-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--rtp-primary-dark);
    border-color: var(--rtp-primary-dark);
}
.btn-accent {
    background-color: var(--rtp-accent);
    border-color: var(--rtp-accent);
    color: #fff;
}
.btn-accent:hover { background-color: var(--rtp-accent-dark); color: #fff; }
.btn, .form-control, .form-select { min-height: 44px; }
.btn-sm { min-height: 34px; }
.btn { touch-action: manipulation; }

/* ---------- Guest layout (login / register / password reset) ---------- */
.guest-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--rtp-primary) 0%, var(--rtp-primary-dark) 100%);
    padding: 1.5rem;
}
.guest-card {
    width: 100%;
    max-width: 420px;
    background: var(--rtp-surface);
    border-radius: 12px;
    box-shadow: 0 20px 45px rgba(0,0,0,.25);
    padding: 2.25rem;
}
.guest-brand {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--rtp-primary);
    font-weight: 700;
    font-size: 1.4rem;
}

/* ---------- App shell: sidebar + topbar ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--rtp-sidebar-width);
    background: var(--rtp-primary);
    color: #e5ecf5;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    overflow-y: auto;
    z-index: 1030;
    transition: transform .2s ease;
}
.app-sidebar .brand {
    padding: 1.25rem 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .5rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.app-sidebar .brand img { max-height: 32px; }
.app-sidebar .nav-link {
    color: #cbd8ea;
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    border-left: 3px solid transparent;
    font-size: .95rem;
}
.app-sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-sidebar .nav-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: var(--rtp-accent);
    font-weight: 600;
}
.app-sidebar .nav-section-title {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .06em;
    color: #92a4bd;
    padding: 1rem 1.25rem .25rem;
}

.app-main {
    margin-left: var(--rtp-sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    background: var(--rtp-surface);
    border-bottom: 1px solid var(--rtp-border);
    padding: .75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

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

.sidebar-toggle { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-backdrop {
        display: none;
        position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1025;
    }
    .sidebar-backdrop.open { display: block; }
}

/* ---------- Dashboard cards ---------- */
.stat-card {
    background: var(--rtp-surface);
    border: 1px solid var(--rtp-border);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    height: 100%;
}
.stat-card .stat-label {
    color: var(--rtp-text-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--rtp-primary);
    margin-top: .25rem;
}
.stat-card .stat-value.positive { color: var(--rtp-success); }
.stat-card .stat-value.negative { color: var(--rtp-danger); }
.stat-card .stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(13,148,136,.12);
    color: var(--rtp-accent);
    font-size: 1.2rem;
}

.section-card {
    background: var(--rtp-surface);
    border: 1px solid var(--rtp-border);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

/* ---------- Status badges ---------- */
.status-badge {
    display: inline-block;
    padding: .3rem .65rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-status-in-inventory { background: #e0f2fe; color: #075985; }
.badge-status-listed { background: #ede9fe; color: #5b21b6; }
.badge-status-sold { background: #dcfce7; color: #166534; }
.badge-status-partial-refund { background: #fef3c7; color: #92400e; }
.badge-status-full-refund { background: #fee2e2; color: #991b1b; }
.badge-status-returned { background: #fee2e2; color: #991b1b; }
.badge-status-archived { background: #e5e7eb; color: #374151; }
.badge-status-default { background: #e5e7eb; color: #374151; }

/* ---------- Responsive tables -> cards on mobile ---------- */
.table-responsive-stack thead { display: table-header-group; }

@media (max-width: 767.98px) {
    .table-responsive-stack table,
    .table-responsive-stack thead,
    .table-responsive-stack tbody,
    .table-responsive-stack th,
    .table-responsive-stack td,
    .table-responsive-stack tr { display: block; width: 100%; }
    .table-responsive-stack thead { display: none; }
    .table-responsive-stack tr {
        background: var(--rtp-surface);
        border: 1px solid var(--rtp-border);
        border-radius: 10px;
        margin-bottom: .85rem;
        padding: .5rem .75rem;
    }
    .table-responsive-stack td {
        border: none;
        padding: .4rem 0;
        display: flex;
        justify-content: space-between;
        gap: .75rem;
        text-align: right;
    }
    .table-responsive-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--rtp-text-muted);
        text-align: left;
    }
}

/* ---------- Image upload / preview ---------- */
.image-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--rtp-border);
    background: #f1f5f9;
}
.image-tile { position: relative; }
.image-tile .image-actions {
    position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
}
.image-tile .badge-primary-photo {
    position: absolute; bottom: 6px; left: 6px;
}
.upload-drop {
    border: 2px dashed var(--rtp-border);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    color: var(--rtp-text-muted);
    background: #f8fafc;
}

/* ---------- Misc ---------- */
.table thead th { color: var(--rtp-text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom-width: 1px; }
.list-inventory-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--rtp-border); }
.profit-positive { color: var(--rtp-success); font-weight: 700; }
.profit-negative { color: var(--rtp-danger); font-weight: 700; }
.breakdown-table td { padding: .35rem .5rem; }
.breakdown-table tr.total-row td { border-top: 2px solid var(--rtp-border); font-weight: 700; }
.spinner-overlay {
    position: fixed; inset: 0; background: rgba(255,255,255,.6);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
}
footer.app-footer { padding: 1rem 1.5rem; color: var(--rtp-text-muted); font-size: .82rem; }
