/* Unified UI layer for all core pages.
 * This file is additive-only in phase 1 to avoid regressions.
 */

/* Shared micro effects */
.hover-lift {
    transition: transform 0.2s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
}

.object-fit-cover {
    object-fit: cover;
}

.fade-in-up {
    animation: tuFadeInUp 0.5s ease forwards;
}

@keyframes tuFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Home tips animation (moved from inline style). */
.tips-scroll-wrapper {
    animation: tipsScroll var(--tips-scroll-duration, 12s) linear infinite;
}

@keyframes tipsScroll {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(calc(-1 * var(--tips-scroll-distance, 30px)));
    }
}

/* Notice icon animation (moved from footer inline style). */
.shake-animation {
    animation: tuShake 1s infinite alternate;
}

@keyframes tuShake {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(10deg);
    }
    50% {
        transform: rotate(0deg);
    }
    75% {
        transform: rotate(-10deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

/* History page cards */
#history-container .history-thumb {
    width: 100% !important;
    height: 195px !important;
    object-fit: cover;
    display: block;
}

#history-container .history-thumb.no-zoom {
    object-fit: contain !important;
    padding: 10px;
    background: #f8f9fa;
    cursor: default !important;
}

#history-container img.no-zoom:hover {
    transform: none !important;
    box-shadow: none !important;
    position: static !important;
    z-index: auto !important;
}

/* AI generate page */
#promptInput:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
    border-color: var(--bs-primary);
}

#resultImage {
    transition: transform 0.3s ease;
}

#resultImage:hover {
    transform: scale(1.02);
}

.result-image-actions {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.result-image-wrap:hover .result-image-actions,
.result-image-wrap:focus-within .result-image-actions {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
    .result-image-actions {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }
}

.prompt-example {
    transition: all 0.2s ease;
}

.prompt-example:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-switch-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.2rem 0.1rem;
    cursor: pointer;
    user-select: none;
}

.ai-switch-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ai-switch-slider {
    width: 2.5rem;
    height: 1.4rem;
    border-radius: 999px;
    background: #e3e8ef;
    border: 1px solid rgba(var(--bs-primary-rgb), 0.25);
    position: relative;
    transition: all 0.22s ease;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.ai-switch-slider::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 1px;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.22s ease;
}

.ai-switch-item:hover .ai-switch-slider {
    border-color: rgba(var(--bs-primary-rgb), 0.45);
}

.ai-switch-input:checked + .ai-switch-slider {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}

.ai-switch-input:checked + .ai-switch-slider::before {
    transform: translateX(1.08rem);
}

.ai-switch-input:focus-visible + .ai-switch-slider {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.16);
}

.ai-switch-text {
    display: inline-flex;
    align-items: center;
}

.history-thumb {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.history-thumb.no-zoom:hover {
    transform: none !important;
    box-shadow: none !important;
}


/* ===== Home Page (from home/home.css) ===== */
.spin-icon {
    animation: spin 1s infinite linear;
}

/* Custom active tab style for better visibility */
/* Custom active tab style for better visibility - Removed to use unified site.css */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

#upload-zone:hover {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
}

#upload-zone.dragover {
    background-color: #eff6ff !important;
    border-color: #3b82f6 !important;
    transform: scale(1.01);
}

/* Upload Queue Styles */
#upload-queue .list-group-item {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background-color 0.2s ease;
}

#upload-queue .list-group-item:last-child {
    border-bottom: none;
}

#upload-queue .list-group-item-success {
    background-color: rgba(25, 135, 84, 0.1);
}

#upload-queue .list-group-item-danger {
    background-color: rgba(220, 53, 69, 0.1);
}

#upload-queue .list-group-item-warning {
    background-color: rgba(255, 193, 7, 0.1);
}

#upload-queue .progress {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

#upload-queue .progress-bar {
    transition: width 0.1s ease;
}

/* ===== Tips Scroll Animation ===== */
.tips-alert {
    background: rgba(13, 202, 240, 0.1);
}

.tips-scroll-container {
    height: 30px;
}

.tips-scroll-wrapper a {
    color: inherit;
    text-decoration: none;
}

.tips-scroll-wrapper a:hover {
    text-decoration: underline;
}

.tips-scroll-wrapper i {
    font-style: normal;
}

.tips-item {
    height: 30px;
    line-height: 30px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Thumbnail Preview ===== */
#thumb-preview-container {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 10px;
    padding: 10px;
    white-space: nowrap;
}

#thumb-preview-container img {
    height: 100px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* ===== Upload Zone ===== */
.upload-card {
    border-radius: 1rem;
    overflow: hidden;
}

.upload-zone {
    background: linear-gradient(135deg, #f8faff 0%, #f0f4ff 50%, #f8faff 100%);
    border: 2px dashed #c7d2fe;
    border-radius: 1rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dbeafe, #ede9fe);
    animation: uploadBounce 2s ease-in-out infinite;
}

.upload-icon {
    font-size: 2.5rem;
    color: #4f46e5;
}

.upload-title {
    font-size: 1.75rem;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.02em;
}

.upload-subtitle {
    font-size: 0.85rem;
    color: #94a3b8 !important;
}

.upload-btn {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border: none;
    padding: 0.6rem 1.8rem;
    font-size: 0.95rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #2563eb, #4f46e5);
}

@keyframes uploadBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Mobile responsive for upload zone */
@media (max-width: 576px) {
    .upload-zone {
        padding: 2rem 1rem !important;
    }
    .upload-icon-wrapper {
        width: 60px;
        height: 60px;
    }
    .upload-icon {
        font-size: 1.8rem;
    }
    .upload-title {
        font-size: 1.3rem;
        word-break: keep-all;
        white-space: nowrap;
    }
    .upload-subtitle {
        font-size: 0.75rem;
    }
    .upload-btn {
        padding: 0.5rem 1.4rem;
        font-size: 0.85rem;
    }
}

/* ===== Result Card ===== */
.result-card {
    border-radius: 1rem;
}

.result-textarea {
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ===== Progress Bar ===== */
.upload-progress-bar {
    height: 10px;
    border-radius: 5px;
}

.spin-icon-lg {
    font-size: 3rem;
}

/* ===== Thumb Preview ===== */
#thumb-preview-container {
    min-height: 120px;
}


/* ===== Admin Page (from admin/admin.css) ===== */
:root {
    --admin-bg: #f6f8fb;
    --admin-surface-shadow: 0 12px 34px rgba(16, 24, 40, .08);
    --admin-border: rgba(16, 24, 40, .10);
    --admin-primary-rgb: 13, 110, 253;
}

body {
    background: var(--admin-bg);
}

/* =========================================
   Fix for Page Shift when Modal Opens
   ========================================= */
/* 
   CRITICAL FIX: 
   Bootstrap sets 'overflow: hidden' on body, which destroys the 'scrolling mechanism'
   needed for 'position: sticky' to work. This causes the sticky sidebar to lose its
   offset and jump to the top (static position).
   
   SOLUTION:
   We force 'overflow: visible' so the body/window scrollbar remains.
   We also remove the padding-right adjustment to prevent horizontal shift.
*/
body.modal-open {
    overflow: visible !important;
    /* Must be visible to keep sticky context */
    padding-right: 0 !important;
}

/* Ensure no other elements get shifted */
body.modal-open .navbar,
body.modal-open .fixed-top,
body.modal-open .sticky-top,
body.modal-open header {
    padding-right: 0 !important;
    margin-right: 0 !important;
}

.admin-surface {
    background: #fff;
    border: 1px solid var(--admin-border);
    box-shadow: var(--admin-surface-shadow);
    border-radius: 1rem;
}

/* =========================================
   Sidebar Styling
   ========================================= */
.admin-sidebar {
    position: sticky;
    top: 90px;
    /* max-height: calc(100vh - 100px); Remove to allow smart scroll */
    /* overflow-y: auto; Remove to allow smart scroll */

    /* Prevent wrapping */
    flex-wrap: nowrap !important;


    /* Desktop: Show thin scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.admin-sidebar::-webkit-scrollbar {
    width: 6px;
    display: block;
    /* Restore for desktop */
}

.admin-sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.admin-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.admin-sidebar .nav-link {
    border-radius: .8rem;
    /* Compact Spacing: Reduced padding from .75rem to .6rem */
    padding: .6rem .85rem;
    /* Compact Spacing: Reduced margin from .35rem to .15rem */
    margin-bottom: .20rem;
    color: #4b5563;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
    /* Slight size adjustment for compactness */
}

.admin-sidebar .nav-link i {
    font-size: 1.1em;
}

.admin-sidebar .nav-link:hover {
    background: rgba(var(--admin-primary-rgb), .06);
    color: var(--bs-primary);
    transform: translateX(3px);
}

.nav-pills .nav-link.active {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0a58ca 100%) !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(var(--admin-primary-rgb), .3);
    /* Slightly subtler shadow */
    transform: translateX(3px);
}

.nav-pills .nav-link.active i {
    color: #ffffff !important;
}

.admin-content {
    border: 1px solid var(--admin-border);
    border-radius: 1rem;
    box-shadow: var(--admin-surface-shadow);
    background: #fff;
    min-height: calc(100vh - 120px);
}

.table thead th {
    white-space: nowrap;
    background-color: #f8f9fa;
    border-bottom: 2px solid #eef2f6;
    font-weight: 600;
    color: #6c757d;
}

.table td,
.table th {
    vertical-align: middle;
}

.code-like {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Mobile & Tablet Optimizations */
@media (max-width: 991.98px) {
    .admin-sidebar {
        position: static;
        max-height: none;
        overflow-y: hidden;
        display: flex;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 10px;
        margin-bottom: 1.5rem;
        -webkit-overflow-scrolling: touch;
        background: transparent;
        padding-left: 0;
        padding-right: 0;
        border: none;
        box-shadow: none;
    }

    /* Only hide scrollbar on Touch Devices (Phones/Tablets) */
    @media (pointer: coarse) {
        .admin-sidebar {
            scrollbar-width: none;
            -ms-overflow-style: none;
        }

        .admin-sidebar::-webkit-scrollbar {
            display: none;
        }
    }

    .admin-sidebar .nav-link {
        white-space: nowrap;
        margin-right: 0.75rem;
        margin-bottom: 0;
        border: 1px solid var(--admin-border);
        background: #fff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
        flex: 0 0 auto;
        padding: 0.6rem 1rem;
    }

    .admin-sidebar .nav-link:hover {
        transform: none;
    }

    .nav-pills .nav-link.active {
        transform: none;
        box-shadow: 0 4px 12px rgba(var(--admin-primary-rgb), .25);
    }

    .admin-content {
        padding: 1.25rem !important;
        background: #fff;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        border: 1px solid rgba(0, 0, 0, 0.05);
    }
}

/* ===== Admin Form Styles ===== */

/* ----- Custom Switch (Toggle) ----- */
.form-check-input[type="checkbox"] {
    cursor: pointer;
}

.form-switch .form-check-input {
    width: 2.75em;
    height: 1.4em;
    border-radius: 2em;
    border: 2px solid #d1d5db;
    background-color: #e9ecef;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23adb5bd'/%3e%3c/svg%3e");
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.form-switch .form-check-input:hover {
    border-color: #adb5bd;
    background-color: #dee2e6;
}

.form-switch .form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.2);
}

.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
    border-color: rgba(var(--bs-primary-rgb), 0.4);
}

/* ----- Custom Checkbox (Square) ----- */
.form-check:not(.form-switch) > .form-check-input[type="checkbox"] {
    width: 1.15em;
    height: 1.15em;
    border: 2px solid #c5ccd6;
    border-radius: 0.3em;
    background-color: #fff;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.form-check:not(.form-switch) > .form-check-input[type="checkbox"]:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.1);
}

.form-check:not(.form-switch) > .form-check-input[type="checkbox"]:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.15);
}

.form-check:not(.form-switch) > .form-check-input[type="checkbox"]:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
    border-color: rgba(var(--bs-primary-rgb), 0.4);
}

/* ----- Custom Radio ----- */
.form-check-input[type="radio"] {
    width: 1.15em;
    height: 1.15em;
    border: 2px solid #c5ccd6;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.form-check-input[type="radio"]:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.1);
}

.form-check-input[type="radio"]:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), 0.15);
}

.form-check-input[type="radio"]:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
    border-color: rgba(var(--bs-primary-rgb), 0.4);
}

/* ----- Switch Label Animation ----- */
.form-switch .form-check-label {
    transition: color 0.2s ease;
    user-select: none;
}

.form-switch .form-check-input:checked ~ .form-check-label {
    color: var(--bs-primary);
}

/* ----- Size Variants ----- */
.form-check-lg .form-check-input {
    transform: scale(1.3);
}

.form-check-xl .form-check-input {
    transform: scale(1.4);
}

/* ===== AI Stats Cards ===== */
.ai-stat-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem 0.6rem;
    align-items: start;
}

.ai-stat-metric {
    min-width: 0;
    text-align: center;
}

.ai-stat-value {
    font-size: clamp(1.28rem, 1.35vw, 1.85rem) !important;
    white-space: nowrap;
    line-height: 1.15;
}

.ai-stat-label {
    font-size: 0.75rem;
    line-height: 1.15;
    white-space: nowrap;
    word-break: keep-all;
}

@media (max-width: 1200px) {
    .ai-stat-value {
        font-size: clamp(1.28rem, 1.7vw, 1.7rem) !important;
    }
}

@media (max-width: 992px) {
    .ai-stat-value {
        font-size: clamp(1.2rem, 1.65vw, 1.5rem) !important;
    }
}

@media (min-width: 768px) and (max-width: 1399.98px) {
    .ai-stat-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-stat-metrics .ai-stat-metric:nth-child(3) {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767.98px) {
    .ai-stat-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* AI stats header layout fixes (narrow desktop + mobile) */
.ai-stats-header {
    gap: 0.55rem;
    flex-wrap: wrap;
}

.ai-stats-title {
    flex: 0 0 auto;
    min-width: 7.5rem;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    margin-right: auto;
}

.ai-stats-controls {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ai-stats-controls .badge {
    white-space: nowrap;
    max-width: 100%;
}

.ai-stats-month-select {
    flex: 0 0 auto;
    min-width: 8.4rem;
    max-width: 11rem;
}

@media (max-width: 1199.98px) {
    .ai-stats-header {
        align-items: flex-start !important;
    }

    .ai-stats-controls {
        flex: 1 1 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 575.98px) {
    .ai-stats-title {
        min-width: 0;
        width: 100%;
        white-space: normal;
        margin-right: 0;
    }

    .ai-stats-controls {
        width: 100%;
        gap: 0.4rem !important;
    }

    .ai-stats-month-select {
        flex: 1 1 100%;
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 767.98px) {
    .admin-content .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    .admin-content .table {
        font-size: 0.875rem;
    }

    .admin-content .table th,
    .admin-content .table td {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        padding: 0.5rem 0.45rem;
    }

    .admin-content .text-nowrap,
    .admin-content .table .text-nowrap {
        white-space: normal !important;
    }

    .admin-content label,
    .admin-content .form-check-label,
    .admin-content .input-group-text,
    .admin-content .btn {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .admin-content .input-group {
        flex-wrap: wrap;
    }

    .admin-content .input-group > .form-control,
    .admin-content .input-group > .form-select,
    .admin-content .input-group > .btn,
    .admin-content .input-group > .input-group-text {
        min-width: 0;
        flex: 1 1 auto;
    }
}

/* ================================================================
   Mobile-First Optimizations (≤576px)
   ================================================================ */
@media (max-width: 576px) {

    /* ── Body & Container ────────────────────────────── */
    body {
        padding-top: 90px !important;
    }

    .main-container {
        padding-top: 8px;
        padding-left: 10px;
        padding-right: 10px;
    }

    /* ── Navbar compact ─────────────────────────────── */
    .navbar {
        padding-top: 0.3rem;
        padding-bottom: 0.15rem;
    }

    .navbar .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    .navbar-brand {
        font-size: 1.1rem;
        gap: 0.3rem;
    }

    .navbar-logo {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }

    .navbar-title {
        font-size: 1rem;
    }

    #navbarContent .nav-link {
        padding: 0.3rem 0.55rem;
        font-size: 0.82rem;
    }

    #navbarContent .nav-link i {
        margin-right: 2px;
    }

    #navbarContent.navbar-collapse {
        margin-top: 0.25rem;
    }

    /* ── Tips alert compact ─────────────────────────── */
    .tips-alert {
        padding: 0.4rem 0.6rem !important;
        margin-bottom: 0.6rem !important;
        font-size: 0.8rem;
    }

    .tips-alert .bi-megaphone-fill {
        font-size: 0.85rem;
    }

    /* ── Identity / quota card compact ──────────────── */
    .alert.shadow-sm {
        padding: 0.45rem 0.65rem !important;
        margin-bottom: 0.6rem !important;
        font-size: 0.82rem;
    }

    .alert.shadow-sm .badge {
        font-size: 0.7em;
        padding: 0.2em 0.45em;
    }

    .alert.shadow-sm .progress {
        height: 4px !important;
        margin-top: 0.2rem;
    }

    .alert.shadow-sm small {
        font-size: 0.78rem;
        line-height: 1.35;
    }

    /* ── Upload zone compact ────────────────────────── */
    .upload-zone {
        padding: 1.5rem 0.8rem !important;
        border-radius: 0.8rem !important;
    }

    .upload-icon-wrapper {
        width: 50px;
        height: 50px;
    }

    .upload-icon {
        font-size: 1.5rem;
    }

    .upload-title {
        font-size: 1.15rem;
    }

    .upload-subtitle {
        font-size: 0.7rem;
    }

    .upload-btn {
        padding: 0.4rem 1.2rem;
        font-size: 0.8rem;
    }

    /* ── Result card compact ────────────────────────── */
    .result-card {
        border-radius: 0.75rem;
    }

    .result-card .card-header {
        padding: 0.6rem 0.8rem 0 !important;
    }

    /* Result tabs: horizontal scroll, text-only, compact */
    #resultTabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 3px !important;
        gap: 2px;
    }

    #resultTabs::-webkit-scrollbar {
        height: 0;
        display: none;
    }

    #resultTabs .nav-item {
        flex: 0 0 auto;
    }

    #resultTabs .nav-link {
        padding: 0.3rem 0.55rem !important;
        font-size: 0.72rem !important;
        white-space: nowrap;
    }

    #resultTabs .nav-link i {
        display: none;
    }

    .result-card .card-body {
        padding: 0.6rem 0.8rem 0.8rem !important;
    }

    .result-textarea {
        font-size: 0.75em;
        rows: 3;
    }

    /* ── Footer compact ─────────────────────────────── */
    footer.footer {
        padding: 0.5rem 0 !important;
    }

    footer.footer p {
        font-size: 0.75rem;
        line-height: 1.8;
    }

    footer.footer .text-secondary,
    footer.footer a {
        margin-right: 0.35rem !important;
    }

    /* ── Ad box ──────────────────────────────────────── */
    .ad-box {
        padding: 0.5rem !important;
        font-size: 0.8rem;
    }

    .container.mb-3 {
        margin-bottom: 0.5rem !important;
    }

    /* ── Notice modal compact ────────────────────────── */
    .modal-dialog-centered .modal-content {
        margin: 0.5rem;
    }

    .modal-body {
        padding: 1rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* ================================================================
   List / Gallery page mobile (≤576px)
   ================================================================ */
@media (max-width: 576px) {

    /* Two-column grid for image cards */
    .row .col-6.col-md-4.col-lg-3 {
        padding-left: 4px;
        padding-right: 4px;
        margin-bottom: 8px;
    }

    /* Tighter cards */
    .row .col-6 .card {
        border-radius: 0.5rem;
    }

    .row .col-6 .card-img-top {
        border-radius: 0.5rem 0.5rem 0 0;
    }

    .row .col-6 .card-footer {
        padding: 0.35rem 0.2rem !important;
        font-size: 0.78rem;
    }

    .row .col-6 .card-footer a,
    .row .col-6 .card-footer .form-check {
        font-size: 0.82rem;
    }

    /* Date filter buttons */
    .btn-group.shadow-sm .btn-sm {
        font-size: 0.72rem;
        padding: 0.2rem 0.45rem;
    }

    /* Batch action buttons */
    .d-flex.flex-wrap.align-items-center.gap-2 {
        gap: 0.35rem !important;
    }
}

/* ================================================================
   Info / detail page mobile (≤576px)
   ================================================================ */
@media (max-width: 576px) {

    /* Header card */
    .card-body .d-flex.align-items-center.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.4rem;
    }

    .card-body .d-flex.gap-2 .btn-sm {
        font-size: 0.78rem;
        padding: 0.2rem 0.6rem;
    }

    /* Info table */
    .info-table td {
        font-size: 0.82rem;
        padding: 0.4rem 0.6rem !important;
    }

    .info-table .label {
        white-space: nowrap;
        width: 85px;
        min-width: 85px;
        font-size: 0.78rem;
    }

    .info-table .value {
        word-break: break-all;
    }

    /* Share card inputs */
    .share-card .input-group {
        flex-wrap: nowrap;
    }

    .share-card .form-control {
        font-size: 0.78rem;
        padding: 0.3rem 0.5rem;
    }

    .share-card .btn {
        font-size: 0.78rem;
        padding: 0.3rem 0.5rem;
        white-space: nowrap;
    }

    .share-card .card-header {
        padding: 0.5rem 0.8rem;
    }

    .share-card .nav-link {
        font-size: 0.78rem;
        padding: 0.3rem 0.5rem;
    }

    /* Image preview */
    .image-preview-container {
        border-radius: 0.5rem;
        margin-bottom: 0.8rem;
    }

    /* Random images at bottom */
    .col-6.col-md-4.col-lg-2 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
        padding: 3px;
    }
}

/* ================================================================
   History page mobile (≤576px)
   ================================================================ */
@media (max-width: 576px) {

    /* History image list */
    .history-image-list .col-6 {
        padding-left: 4px;
        padding-right: 4px;
    }

    .history-image-list .card {
        border-radius: 0.5rem;
    }

    .history-image-list .card-body {
        padding: 0.4rem;
    }
}

/* ================================================================
   Tablet adjustments (577px – 768px)
   ================================================================ */
@media (min-width: 577px) and (max-width: 768px) {

    body {
        padding-top: 88px !important;
    }

    .main-container {
        padding-top: 10px;
    }

    .tips-alert {
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem !important;
    }

    .upload-zone {
        padding: 1.8rem 1rem !important;
    }

    footer.footer p {
        font-size: 0.8rem;
    }

    .row .col-6.col-md-4.col-lg-3 {
        flex: 0 0 33.333%;
        max-width: 33.333%;
    }
}

/* Horizontal nav body padding for mid-size screens */
@media (min-width: 769px) and (max-width: 991.98px) {
    body {
        padding-top: 86px !important;
    }
}
