/* Modern CSS Stylesheet for User Management Web App */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #e0e7ff;
    --bg-page: #edf2f7;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #334155;
    --border-color: #cbd5e1;
    --border-focus: #6366f1;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-border: #fca5a5;
    --danger-text: #991b1b;
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-border: #6ee7b7;
    --success-text: #065f46;
    --info-bg: #e0e7ff;
    --info-border: #a5b4fc;
    --info-text: #312e81;
    --accent: #d97706;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.12), 0 2px 4px -2px rgb(0 0 0 / 0.08);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.14), 0 4px 6px -4px rgb(0 0 0 / 0.08);
    --radius-md: 8px;
    --radius-lg: 12px;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Header & Navigation */
.navbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.65rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    gap: 1rem;
}

.nav-brand-group {
    display: flex;
    align-items: center;
}

.nav-header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    order: 3;
}

.mobile-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    transition: all 0.15s ease;
}

.mobile-nav-toggle:hover {
    background: var(--bg-page);
    border-color: var(--border-focus);
}

.main-nav-wrapper {
    display: flex;
    align-items: center;
    order: 2;
    flex-shrink: 1;
    min-width: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    text-decoration: none !important;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: bold;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: clamp(0.35rem, 0.9vw, 0.85rem);
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: nowrap;
}

.nav-links li {
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-link {
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.35rem 0.55rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background-color: var(--primary-light);
    text-decoration: none;
}

.nav-link.nav-link-alert {
    color: #ef4444 !important;
    font-weight: 700 !important;
}

.nav-link.nav-link-alert:hover {
    color: #dc2626 !important;
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.35rem 0.65rem;
    border-radius: 9999px;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Layout container */
.main-content {
    flex: 1;
    max-width: 1000px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1.25rem;
}

/* Alerts / Notifications */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-weight: 500;
}

.alert-icon {
    font-size: 1.15rem;
    line-height: 1.2;
    flex-shrink: 0;
}

.alert-success {
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.alert-error {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}

.alert-info {
    background-color: var(--info-bg);
    border: 1px solid var(--info-border);
    color: var(--info-text);
}

/* Card Styles */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 2rem;
    margin-bottom: 2rem;
}

.card-auth {
    max-width: 440px;
    margin: 3rem auto;
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-select {
    width: 100%;
    height: 42px;
    padding: 0.6rem 2.25rem 0.6rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    color: var(--text-main);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem 1rem;
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--bg-page);
}

/* Subitem Toggle Switch & Card matching .form-input design */
.subitem-toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 42px;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
    margin: 0;
}

.subitem-toggle-card:hover {
    border-color: var(--primary);
}

.subitem-toggle-card.checked {
    background-color: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.5);
}

.subitem-toggle-text {
    font-size: 0.88rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.15s;
}

.subitem-toggle-text.active {
    color: #059669;
}

.subitem-toggle-text.inactive {
    color: var(--text-muted);
}

.subitem-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

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

.subitem-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: 0.2s;
    border-radius: 22px;
}

.subitem-switch-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.subitem-switch input:checked + .subitem-switch-slider {
    background-color: #10b981;
}

.subitem-switch input:checked + .subitem-switch-slider:before {
    transform: translateX(16px);
}

.form-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-block {
    width: 100%;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.user-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
}

.user-summary-text h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.user-summary-text p {
    color: #e0e7ff;
    font-size: 0.95rem;
}

.user-meta-badge {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.user-summary-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.user-summary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-main);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    line-height: 1.4;
}

.user-summary-btn:hover {
    background: #ffffff;
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
    text-decoration: none;
}

.user-summary-btn-admin {
    color: #b45309;
}

.user-summary-btn-messages {
    color: var(--primary);
}

.user-summary-btn-edit {
    color: var(--text-main);
}

.user-summary-btn-2fa-active {
    color: #065f46;
}

.user-summary-btn-2fa-setup {
    background: #fef08a;
    color: #854d0e;
    border-color: #fde047;
    font-weight: 700;
}

.user-summary-btn-2fa-setup:hover {
    background: #fef9c3;
    color: #713f12;
}

.user-summary-btn-profile {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.4);
}

.user-summary-btn-profile:hover {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.user-badge-admin-tag {
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 700;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem auto;
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Feature grid on home */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
}

.feature-box h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.feature-box p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

.footer-link:hover {
    color: var(--primary) !important;
    text-decoration: underline !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .user-summary {
        flex-direction: column;
        align-items: flex-start;
    }
    .hero h1 {
        font-size: 2rem;
    }
    .card {
        padding: 1.25rem;
    }
}

/* Item & Upload Styles */
.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.item-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.item-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.item-card-link {
    text-decoration: none !important;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.thumbnail-container {
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--border-color);
    overflow: hidden;
    position: relative;
}

.thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s ease;
}

.item-card:hover .thumbnail-img {
    transform: scale(1.04);
}

.item-card-body {
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.item-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.75rem;
    flex: 1;
}

.item-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* Item List View */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.item-list-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.item-list-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.item-list-card .thumbnail-container {
    width: 220px;
    min-width: 220px;
    aspect-ratio: auto;
    height: 100%;
    min-height: 150px;
}

.item-list-card .item-card-body {
    padding: 1.25rem 1.5rem;
    flex: 1;
}

@media (max-width: 640px) {
    .item-list-card {
        flex-direction: column;
    }
    .item-list-card .thumbnail-container {
        width: 100%;
        min-width: 100%;
        aspect-ratio: 16 / 10;
        min-height: auto;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin: 2rem 0;
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    display: block;
}

.empty-state-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.empty-state-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 450px;
    margin: 0 auto 1.5rem auto;
}

/* Detail View Layout */
.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
    gap: 2rem;
    align-items: start;
}

@media (max-width: 860px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }
}

.detail-image-box {
    background: #0f172a;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    max-height: 600px;
}

.detail-img {
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
    display: block;
}

.detail-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
}

.detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
    margin-bottom: 1rem;
    word-break: break-word;
}

.detail-desc-box {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 1.5rem;
}

.detail-meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

.detail-meta-table tr {
    border-bottom: 1px solid #f1f5f9;
}

.detail-meta-table td {
    padding: 0.5rem 0;
}

.detail-meta-table td:first-child {
    color: var(--text-muted);
    font-weight: 500;
    width: 35%;
}

.detail-meta-table td:last-child {
    text-align: right;
    font-weight: 600;
    color: var(--text-main);
}

.image-preview-box {
    margin-top: 1rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    text-align: center;
    max-height: 250px;
    display: none;
    overflow: hidden;
}

.image-preview-box img {
    max-height: 230px;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
}

/* Superitem & Publishing Badges */
.superitem-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    border: 1px solid #cbd5e1;
    background-color: #f1f5f9;
    color: #475569;
    text-transform: capitalize;
}

.superitem-car {
    background-color: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.superitem-motorbike {
    background-color: #fffbeb;
    color: #b45309;
    border-color: #fde68a;
}

.superitem-company {
    background-color: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.badge-published {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.badge-draft {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

/* Red Dot Notification Indicators */
.red-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
    margin-left: 0.35rem;
    box-shadow: 0 0 0 2px white;
    vertical-align: middle;
}

.thread-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background-color: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px white;
    flex-shrink: 0;
    margin-right: 0.4rem;
}

/* Individual Message Red Dot & Unread Indicators */
.message-red-dot,
.message-dot.red-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    background-color: #ef4444;
    border-radius: 50%;
    box-shadow: 0 0 0 2px white, 0 1px 3px rgba(239, 68, 68, 0.35);
    margin-right: 0.35rem;
    margin-left: 0;
    vertical-align: middle;
    animation: messageDotPulse 1.8s infinite ease-in-out;
}

@keyframes messageDotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.85; }
}

.message-unread-indicator {
    display: inline-flex;
    align-items: center;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    vertical-align: middle;
}

.message-unread-indicator .message-dot,
.message-unread-indicator .red-dot {
    margin-right: 0.3rem;
}

.chat-bubble-row.is-unread .chat-bubble-received,
.chat-bubble-received.chat-bubble-unread {
    border-left: 4px solid #ef4444;
    background: #fff8f8;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.chat-bubble-unread-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #fee2e2;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    margin-bottom: 0.45rem;
    border: 1px solid #fca5a5;
}

/* Chat Message Delete Button */
.chat-msg-delete-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    transition: color 0.15s ease, opacity 0.15s ease;
    opacity: 0.7;
    margin-left: 0.2rem;
}

.chat-msg-delete-btn:hover {
    color: var(--danger);
    opacity: 1;
}

.chat-bubble-row .chat-msg-delete-form {
    display: inline;
}

/* Bulk Message Selection Toolbar & Checkbox Styles */
.chat-bulk-toolbar {
    padding: 0.65rem 1.25rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    animation: bulkToolbarSlide 0.2s ease-out;
}

@keyframes bulkToolbarSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-bubble-wrapper {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    max-width: 85%;
    width: fit-content;
}

.chat-bubble-row.sent .chat-bubble-wrapper {
    flex-direction: row-reverse;
}

.message-select-checkbox {
    width: 17px;
    height: 17px;
    cursor: pointer;
    accent-color: var(--danger);
    flex-shrink: 0;
    opacity: 0.45;
    transition: opacity 0.15s ease, transform 0.15s ease;
    border-radius: 4px;
}

.chat-bubble-row:hover .message-select-checkbox,
.message-select-checkbox:checked,
.chat-pane.selection-active .message-select-checkbox {
    opacity: 1;
    transform: scale(1.1);
}

.chat-bubble-row.is-selected .chat-bubble {
    outline: 2px solid var(--danger);
    outline-offset: 1px;
}



/* Messaging System Layout */
.messages-container {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-height: 600px;
    overflow: hidden;
}

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

.threads-sidebar {
    border-right: 1px solid var(--border-color);
    background: var(--bg-page);
    display: flex;
    flex-direction: column;
}

.threads-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
}

.threads-list {
    flex: 1;
    overflow-y: auto;
    max-height: 650px;
}

.thread-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: inherit;
    text-decoration: none !important;
    transition: background 0.15s ease;
    cursor: pointer;
}

.thread-item:hover {
    background: var(--bg-page);
}

.thread-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.thread-item.has-unread {
    background: var(--danger-bg);
}

.thread-item.has-unread:hover {
    background: #fee2e2;
}

.thread-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    overflow: hidden;
}

.thread-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thread-info {
    flex: 1;
    min-width: 0;
}

.thread-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.thread-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.thread-snippet {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat View */
.chat-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.chat-messages {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: var(--bg-page);
}

.chat-bubble-row {
    display: flex;
    flex-direction: column;
}

.chat-bubble-row.sent {
    align-items: flex-end;
}

.chat-bubble-row.received {
    align-items: flex-start;
}

.chat-bubble {
    width: fit-content;
    max-width: 100%;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-lg);
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
}

.chat-bubble-text {
    display: inline-block;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

.chat-bubble-sent {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-bubble-received {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 2px;
}

.chat-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    padding: 0 0.25rem;
}

.chat-form-box {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

/* Image reference box in chat */
.image-reference-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    text-decoration: none !important;
}

.image-reference-card img {
    width: 48px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
}

.image-reference-card .ref-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary);
}

/* Admin Portal Styles */
.badge-admin {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-user {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th {
    background: var(--bg-page);
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.admin-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background-color: var(--bg-page);
}

.admin-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-stat-icon {
    font-size: 2rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-color);
    border-radius: var(--radius-md);
}

.emoji-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.15s ease;
}

.emoji-btn:hover {
    background: var(--border-color);
    border-color: var(--primary);
    transform: scale(1.1);
}

/* Item Viewer, Arrows & Counter (Max 5 images per item) */
.item-viewer-container {
    position: relative;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 0.85rem;
    box-shadow: var(--shadow-sm);
    min-height: 260px;
    max-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.item-main-image {
    width: 100%;
    max-height: 380px;
    object-fit: contain;
    display: block;
    transition: opacity 0.2s ease-in-out;
}

.item-counter-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(15, 23, 42, 0.75);
    color: white;
    backdrop-filter: blur(8px);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.item-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow-md);
    line-height: 1;
    padding: 0;
}

.item-nav-arrow:hover {
    background: rgba(37, 99, 235, 0.95);
    border-color: rgba(255, 255, 255, 0.7);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.item-nav-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.item-nav-arrow.prev {
    left: 1rem;
}

.item-nav-arrow.next {
    right: 1rem;
}

.item-thumbs-row {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding: 0.25rem 0 0.5rem 0;
}

.item-thumb-btn {
    position: relative;
    border: 3px solid transparent;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--border-color);
    padding: 0;
    width: 84px;
    height: 64px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.item-thumb-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-thumb-btn:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.item-thumb-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
}

.item-thumb-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.2;
}

.item-count-pill {
    position: absolute;
    bottom: 0.6rem;
    right: 0.6rem;
    background: rgba(15, 23, 42, 0.85);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 9999px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.upload-preview-card {
    position: relative;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    padding: 0.35rem;
    text-align: center;
}

.upload-preview-card.is-starting {
    border-color: #10b981;
    background: #ecfdf5;
}

.upload-preview-card img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}

.upload-card-label {
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 0.35rem;
    color: var(--text-main);
}

.upload-starting-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #059669;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Item Image Management Cards (Edit, Reorder, Replace, Delete) */
.item-edit-card {
    background: var(--bg-page);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.item-edit-card:hover {
    border-color: #cbd5e1;
}

.item-edit-card.is-starting {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.1);
}

.item-edit-thumb {
    width: 64px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: block;
    background: var(--border-color);
}

.item-starting-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.item-order-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.active-superitem-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.item-replace-box {
    margin-top: 0.6rem;
    padding: 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Modal Dialog Styling */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-backdrop.active {
    display: flex;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    animation: modalFadeIn 0.18s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s;
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-page);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* Pager / Pagination Styles */
/* Modern Responsive Pagination */
.pager-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    margin: 2rem 0 1.5rem 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
    width: 100%;
}

.pager-controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    max-width: 100%;
}

.pager-numbers {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.pager-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.35rem;
    color: var(--text-muted);
    font-weight: 700;
    user-select: none;
}

.pager-jump-wrapper {
    display: inline-flex;
    align-items: center;
}

.pager-jump-select {
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    cursor: pointer;
    height: 38px;
    outline: none;
    transition: border-color 0.15s ease;
}

.pager-jump-select:focus {
    border-color: var(--primary);
}

.pager-footer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s ease;
    min-width: 38px;
    height: 38px;
}

.pager-btn:hover:not(.disabled):not(.active) {
    background: var(--bg-page);
    border-color: #94a3b8;
    color: var(--primary);
}

.pager-btn.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    cursor: default;
}

.pager-btn.disabled {
    background: var(--bg-page);
    color: #94a3b8;
    border-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}

.pager-info {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
    font-weight: 500;
}

/* Mobile Portrait Mode: Ultra-clean 1-line Pager */
@media (max-width: 580px) {
    .pager-controls-row {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .pager-numbers {
        display: none;
    }

    .pager-jump-wrapper {
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .pager-jump-select {
        width: 100%;
        max-width: 160px;
        text-align: center;
    }

    .pager-btn.pager-prev-btn,
    .pager-btn.pager-next-btn {
        flex: 0 0 auto;
        padding: 0.4rem 0.65rem;
        font-size: 0.82rem;
    }
}

/* Admin Portal Section Chooser Tabs */
.admin-tab-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.75rem;
    padding-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.admin-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    white-space: nowrap;
}

.admin-tab-btn:hover {
    color: var(--primary);
    background: var(--bg-page);
}

.admin-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
    background: transparent;
}

.admin-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #e2e8f0;
    color: var(--text-main);
    transition: all 0.15s ease;
}

.admin-tab-btn.active .admin-tab-badge {
    background: #eff6ff;
    color: var(--primary);
}

.admin-tab-pane {
    display: block;
}

.admin-tab-pane.is-hidden {
    display: none !important;
}

.admin-stat-card-clickable {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.admin-stat-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Dark Theme Layout Variables & Component Adjustments
   ========================================================================== */
[data-theme="dark"] {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-light: #1e1b4b;
    --bg-page: #0b0f19;
    --bg-card: #151d30;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #24324a;
    --border-focus: #818cf8;
    --danger: #f87171;
    --danger-bg: rgba(69, 10, 10, 0.4);
    --danger-border: #991b1b;
    --danger-text: #fecaca;
    --success: #34d399;
    --success-bg: rgba(6, 78, 59, 0.4);
    --success-border: #059669;
    --success-text: #a7f3d0;
    --info-bg: rgba(30, 27, 75, 0.45);
    --info-border: #4f46e5;
    --info-text: #c7d2fe;
    --accent: #fbbf24;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.6);
    color-scheme: dark;
}

[data-theme="dark"] .alert-success {
    background-color: rgba(6, 78, 59, 0.4);
    border-color: #059669;
    color: #a7f3d0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .alert-error {
    background-color: rgba(69, 10, 10, 0.4);
    border-color: #991b1b;
    color: #fecaca;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .alert-info {
    background-color: rgba(30, 27, 75, 0.45);
    border-color: #4f46e5;
    color: #c7d2fe;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .navbar {
    background-color: #111827;
    border-bottom-color: #1f2937;
}

[data-theme="dark"] .btn-secondary {
    background-color: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] .btn-secondary:hover {
    background-color: #334155;
    color: #ffffff;
    border-color: #475569;
}

[data-theme="dark"] .admin-tab-btn:hover {
    background: #1e293b;
}

[data-theme="dark"] .admin-tab-badge {
    background: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .admin-tab-btn.active .admin-tab-badge {
    background: #1e1b4b;
    color: #a5b4fc;
}

[data-theme="dark"] .superitem-pill {
    background: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

[data-theme="dark"] .superitem-pill:hover {
    background: #334155;
    color: #ffffff;
}

[data-theme="dark"] .superitem-pill.active {
    background: #4f46e5;
    color: #ffffff;
    border-color: #6366f1;
}

[data-theme="dark"] .superitem-badge {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

[data-theme="dark"] .superitem-car {
    background-color: #1e1b4b;
    color: #93c5fd;
    border-color: #2563eb;
}

[data-theme="dark"] .superitem-motorbike {
    background-color: #451a03;
    color: #fde68a;
    border-color: #b45309;
}

[data-theme="dark"] .superitem-company {
    background-color: #052e16;
    color: #86efac;
    border-color: #16a34a;
}

[data-theme="dark"] .image-reference-card {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .image-reference-card .ref-title {
    color: #93c5fd;
}

[data-theme="dark"] .pager-btn {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .pager-btn:hover:not(.disabled):not(.active) {
    background: #334155;
    border-color: #64748b;
    color: #ffffff;
}

[data-theme="dark"] .pager-btn.disabled {
    background: #0f172a;
    color: #64748b;
    border-color: #1e293b;
}

[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
    background-color: #151d30;
    color: #f1f5f9;
}

[data-theme="dark"] .badge-draft,
[data-theme="dark"] .badge-user {
    background-color: #1e293b;
    color: #cbd5e1;
    border-color: #334155;
}

[data-theme="dark"] .chat-bulk-toolbar {
    background: #111827;
}

[data-theme="dark"] .chat-bubble-row.is-unread .chat-bubble-received,
[data-theme="dark"] .chat-bubble-received.chat-bubble-unread {
    background: #2b1115;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .upload-preview-card.is-starting {
    border-color: #10b981;
    background: #064e3b;
}

[data-theme="dark"] .item-edit-card.is-starting {
    background: #052e16;
    border-color: #16a34a;
}

[data-theme="dark"] .item-starting-pill {
    background: #052e16;
    color: #86efac;
    border-color: #16a34a;
}

[data-theme="dark"] .item-order-pill {
    background: #082f49;
    color: #7dd3fc;
    border-color: #0284c7;
}

[data-theme="dark"] .item-viewer-container {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .item-nav-arrow {
    background: rgba(15, 23, 42, 0.8);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .item-nav-arrow:hover {
    background: rgba(37, 99, 235, 0.95);
    border-color: rgba(255, 255, 255, 0.6);
    color: #ffffff;
}

[data-theme="dark"] .active-superitem-pill {
    background: #082f49;
    color: #7dd3fc;
    border-color: #0284c7;
}

[data-theme="dark"] .user-summary {
    background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 100%);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] .user-summary-btn {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .user-summary-btn:hover {
    background: #334155;
    color: #ffffff;
    border-color: #475569;
}

[data-theme="dark"] .user-summary-btn-admin {
    background: rgba(180, 83, 9, 0.25);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .user-summary-btn-admin:hover {
    background: rgba(180, 83, 9, 0.45);
    color: #fef3c7;
    border-color: rgba(245, 158, 11, 0.6);
}

[data-theme="dark"] .user-summary-btn-messages {
    background: rgba(99, 102, 241, 0.22);
    color: #c7d2fe;
    border-color: rgba(99, 102, 241, 0.4);
}

[data-theme="dark"] .user-summary-btn-messages:hover {
    background: rgba(99, 102, 241, 0.4);
    color: #ffffff;
    border-color: rgba(99, 102, 241, 0.6);
}

[data-theme="dark"] .user-summary-btn-edit {
    background: #1e293b;
    color: #f1f5f9;
    border-color: #334155;
}

[data-theme="dark"] .user-summary-btn-edit:hover {
    background: #334155;
    color: #ffffff;
    border-color: #64748b;
}

[data-theme="dark"] .user-summary-btn-2fa-active {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.4);
}

[data-theme="dark"] .user-summary-btn-2fa-active:hover {
    background: rgba(16, 185, 129, 0.35);
    color: #a7f3d0;
    border-color: rgba(16, 185, 129, 0.6);
}

[data-theme="dark"] .user-summary-btn-2fa-setup {
    background: rgba(202, 138, 4, 0.25);
    color: #fde047;
    border-color: rgba(234, 179, 8, 0.45);
}

[data-theme="dark"] .user-summary-btn-2fa-setup:hover {
    background: rgba(202, 138, 4, 0.4);
    color: #ffffff;
}

[data-theme="dark"] .user-summary-btn-profile {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .user-summary-btn-profile:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

[data-theme="dark"] .user-badge-admin-tag {
    background: rgba(255, 255, 255, 0.18);
    color: #e0e7ff;
}

/* Theme Toggle Button (Navbar) */
.theme-toggle-btn,
.lang-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
}

.theme-toggle-btn:hover,
.lang-toggle-btn:hover {
    color: var(--text-main);
    border-color: var(--border-focus);
    background: var(--bg-page);
}

.lang-flag {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.theme-toggle-icon {
    font-size: 1rem;
    line-height: 1;
}

[data-theme="dark"] .theme-toggle-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-toggle-icon-light {
    display: inline-block;
}

:root:not([data-theme="dark"]) .theme-toggle-icon-dark {
    display: inline-block;
}

:root:not([data-theme="dark"]) .theme-toggle-icon-light {
    display: none;
}

/* Theme Preference Choice Cards in edit_profile.php */
.theme-choice-card {
    display: block;
    position: relative;
    padding: 1rem 1.1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-choice-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-choice-card.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.theme-choice-card input[type="radio"] {
    position: absolute;
    top: 1rem;
    right: 1rem;
    accent-color: var(--primary);
}

.theme-choice-content {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

/* Mobile PWA & Touch Experience Enhancements */
.mobile-bottom-dock {
    display: none;
}

@media (max-width: 768px) {
    body {
        padding-bottom: 70px;
    }

    .mobile-bottom-dock {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 62px;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .mobile-dock-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        color: var(--text-muted);
        text-decoration: none !important;
        font-size: 0.72rem;
        font-weight: 500;
        transition: color 0.15s ease;
        padding: 4px 0;
    }

    .mobile-dock-icon {
        font-size: 1.25rem;
        line-height: 1.2;
        margin-bottom: 2px;
    }

    .mobile-dock-item.active,
    .mobile-dock-item:hover {
        color: var(--primary);
        font-weight: 700;
    }

    .mobile-dock-item.active .mobile-dock-icon {
        transform: scale(1.1);
        transition: transform 0.15s ease;
    }

    /* Touch target comfort on mobile */
    .pager-btn {
        min-height: 38px;
        min-width: 38px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-container {
        padding: 0.5rem 1rem;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .mobile-nav-toggle {
        display: inline-flex;
    }

    .main-nav-wrapper {
        display: none;
        width: 100%;
        flex-basis: 100%;
        order: 4;
        margin-top: 0.65rem;
        padding-top: 0.65rem;
        border-top: 1px solid var(--border-color);
    }

    .main-nav-wrapper.is-open {
        display: block;
        animation: navFadeDown 0.18s ease-out;
    }

    @keyframes navFadeDown {
        from { opacity: 0; transform: translateY(-6px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .main-nav-wrapper .nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0.35rem;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .main-nav-wrapper .nav-links li {
        width: 100%;
    }

    .main-nav-wrapper .nav-link,
    .main-nav-wrapper .user-badge,
    .main-nav-wrapper .btn {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 0.65rem 0.85rem;
        border-radius: var(--radius-md);
        box-sizing: border-box;
    }

    .item-card, .item-list-card, .btn {
        -webkit-tap-highlight-color: rgba(79, 70, 229, 0.15);
    }
}

/* Dedicated Edit Workspace Grid */
.edit-workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 1.25fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 900px) {
    .edit-workspace-grid,
    .detail-container {
        grid-template-columns: 1fr !important;
    }
}
