/* ============================================================
   FitChallenge — Main Stylesheet
   Reset, typography, layout, components, utilities, responsive
   ============================================================ */

/* ---- Reset ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-slow), color var(--transition-slow);
    min-height: 100vh;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-green-hover);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-md); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--accent-green); }
.text-danger { color: var(--accent-red); }
.text-info { color: var(--accent-blue); }
.text-warning { color: var(--accent-amber); }

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
    transition: width var(--transition-slow), transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: var(--space-5) var(--space-5);
    gap: var(--space-3);
    min-height: var(--navbar-height);
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-3);
}

.sidebar-section {
    margin-bottom: var(--space-6);
}

.sidebar-section-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-1);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
    white-space: nowrap;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.sidebar-link .icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
}

.sidebar-link .badge {
    margin-left: auto;
    background: var(--accent-red);
    color: white;
    font-size: var(--font-size-xs);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-semibold);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--space-4);
    border-top: 1px solid var(--border-light);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--bg-hover);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--accent-green-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-green);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-username {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.page-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-8) var(--space-6);
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.page-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
}

.page-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    overflow: hidden;
}

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

.card-clickable:hover {
    transform: translateY(-2px);
}

.card-body {
    padding: var(--space-6);
}

.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

.card-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
    background: var(--bg-input);
}

/* Stat Card */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: var(--space-2);
}

.stat-card .stat-icon.green {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.stat-card .stat-icon.blue {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.stat-card .stat-icon.red {
    background: var(--accent-red-light);
    color: var(--accent-red);
}

.stat-card .stat-icon.amber {
    background: var(--accent-amber-light);
    color: var(--accent-amber);
}

.stat-card .stat-icon.purple {
    background: var(--accent-purple-light);
    color: var(--accent-purple);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: var(--font-weight-medium);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: 1;
}

.stat-change {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.stat-change.positive {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.stat-change.negative {
    background: var(--accent-red-light);
    color: var(--accent-red);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: 1.5;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
}

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

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    color: white;
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-outline-primary {
    background: transparent;
    color: var(--accent-green);
    border-color: var(--accent-green);
}

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

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: var(--space-3) var(--space-8);
    font-size: var(--font-size-md);
    border-radius: var(--radius-lg);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-block {
    width: 100%;
}

/* ---- Forms ---- */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-green-light);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.is-invalid {
    border-color: var(--accent-red);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px var(--accent-red-light);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236b7194' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-text {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--accent-red);
    margin-top: var(--space-1);
}

.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
    cursor: pointer;
}

/* File Upload */
.file-upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-6);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.file-upload:hover {
    border-color: var(--accent-green);
    background: var(--accent-green-light);
}

.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-upload-icon {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.file-upload-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.file-upload-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Image Preview */
.image-preview {
    position: relative;
    display: inline-block;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.image-preview img {
    width: 100%;
    max-width: 300px;
    object-fit: cover;
}

.image-preview .remove-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    background: var(--accent-red);
    color: white;
    border-radius: var(--radius-full);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    cursor: pointer;
}

/* ---- Avatar ---- */
.avatar {
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--accent-green-light);
    color: var(--accent-green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
    overflow: hidden;
    flex-shrink: 0;
}

.avatar-xs { width: 24px; height: 24px; font-size: var(--font-size-xs); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--font-size-xs); }
.avatar-md { width: 40px; height: 40px; font-size: var(--font-size-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--font-size-lg); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--font-size-2xl); }
.avatar-2xl { width: 120px; height: 120px; font-size: var(--font-size-4xl); }

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

.avatar-group {
    display: flex;
}

.avatar-group .avatar {
    border: 2px solid var(--bg-card);
    margin-left: -8px;
}

.avatar-group .avatar:first-child {
    margin-left: 0;
}

/* ---- Badge / Tags ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    line-height: 1.5;
}

.badge-green {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.badge-red {
    background: var(--accent-red-light);
    color: var(--accent-red);
}

.badge-blue {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.badge-amber {
    background: var(--accent-amber-light);
    color: var(--accent-amber);
}

.badge-gray {
    background: var(--bg-badge);
    color: var(--text-secondary);
}

/* ---- Progress Bar ---- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar-lg {
    height: 12px;
}

/* Circular progress */
.circular-progress {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.circular-progress svg {
    transform: rotate(-90deg);
}

.circular-progress .progress-text {
    position: absolute;
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

/* ---- Table ---- */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--bg-input);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

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

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-6);
    overflow-x: auto;
}

.tab {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-green);
    border-bottom-color: var(--accent-green);
}

/* ---- Bottom Navigation (Mobile) ---- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-sticky);
    padding: 0 var(--space-2);
}

.bottom-nav-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    position: relative;
    text-decoration: none;
}

.bottom-nav-link:hover,
.bottom-nav-link.active {
    color: var(--accent-green);
}

.bottom-nav-link .icon {
    font-size: 1.3rem;
}

.bottom-nav-link .nav-badge {
    position: absolute;
    top: 2px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: var(--accent-red);
    color: white;
    border-radius: var(--radius-full);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-weight-bold);
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: slideInRight var(--transition-spring) forwards;
    font-size: var(--font-size-sm);
}

.toast.toast-success { border-left: 3px solid var(--accent-green); }
.toast.toast-error { border-left: 3px solid var(--accent-red); }
.toast.toast-info { border-left: 3px solid var(--accent-blue); }
.toast.toast-warning { border-left: 3px solid var(--accent-amber); }

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: var(--font-weight-semibold);
    margin-bottom: 2px;
}

.toast-message {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

.toast-close {
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--bg-hover);
}

.toast-exit {
    animation: slideOutRight var(--transition-base) forwards;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--font-size-sm);
    max-width: 400px;
    margin: 0 auto var(--space-6);
}

/* ---- Dropdown ---- */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
    padding: var(--space-2);
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    transition: background var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-2) 0;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95);
    transition: transform var(--transition-spring);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ---- Grid Helpers ---- */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Flex Helpers ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.flex-1 { flex: 1; }

/* ---- Spacing Helpers ---- */
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-4 { padding: var(--space-4); }
.p-5 { padding: var(--space-5); }
.p-6 { padding: var(--space-6); }

/* ---- Text Helpers ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--font-size-sm); }
.text-xs { font-size: var(--font-size-xs); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Misc ---- */
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }
.rounded-full { border-radius: var(--radius-full); }

.divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-6) 0;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.animate-fade-in { animation: fadeIn var(--transition-base) ease forwards; }
.animate-fade-in-up { animation: fadeInUp var(--transition-slow) ease forwards; }
.animate-scale-in { animation: scaleIn var(--transition-spring) forwards; }

/* Stagger children */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-green);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

/* ---- Auth Pages ---- */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: var(--space-6);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-10);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.auth-logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
}

.auth-logo-text {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
}

.auth-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    text-align: center;
    margin-bottom: var(--space-2);
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-8);
}

.auth-footer {
    text-align: center;
    margin-top: var(--space-6);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--accent-green);
    font-weight: var(--font-weight-semibold);
}

/* ---- Photo Gallery ---- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
}

.photo-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    aspect-ratio: 3/4;
    cursor: pointer;
    transition: transform var(--transition-base);
}

.photo-card:hover {
    transform: scale(1.02);
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-4);
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
}

.photo-card-date {
    font-size: var(--font-size-xs);
    opacity: 0.8;
}

.photo-card-type {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* ---- Comparison View ---- */
.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

.compare-card {
    text-align: center;
}

.compare-card img {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.compare-label {
    margin-top: var(--space-3);
    font-weight: var(--font-weight-semibold);
    color: var(--text-secondary);
}

/* ---- Leaderboard ---- */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
}

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

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

.leaderboard-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
}

.leaderboard-rank.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA000);
    color: white;
}

.leaderboard-rank.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #9E9E9E);
    color: white;
}

.leaderboard-rank.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #A0522D);
    color: white;
}

.leaderboard-rank.rank-other {
    background: var(--bg-badge);
    color: var(--text-muted);
}

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

.leaderboard-name {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-sm);
}

.leaderboard-stats {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.leaderboard-percentage {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-md);
    color: var(--accent-green);
}

/* ---- Activity Feed ---- */
.activity-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) 0;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--accent-green);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: var(--line-height-relaxed);
}

.activity-text strong {
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold);
}

.activity-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Notification Items ---- */
.notification-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition-fast);
    cursor: pointer;
}

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

.notification-item.unread {
    background: var(--accent-green-light);
}

.notification-item.unread:hover {
    background: var(--accent-green-bg);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

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

.notification-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-primary);
}

.notification-message {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.notification-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ---- Messages (Django messages framework) ---- */
.messages-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.alert {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    animation: slideInRight var(--transition-spring) forwards;
    min-width: 300px;
    max-width: 420px;
}

.alert-success {
    background: var(--bg-card);
    color: var(--accent-green);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-green);
}

.alert-error {
    background: var(--bg-card);
    color: var(--accent-red);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-red);
}

.alert-warning {
    background: var(--bg-card);
    color: var(--accent-amber);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-amber);
}

.alert-info {
    background: var(--bg-card);
    color: var(--accent-blue);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
}

.alert-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.7;
    font-size: 1.25rem;
}

.alert-close:hover {
    opacity: 1;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
    }

    .bottom-nav {
        display: block;
    }

    .page-container {
        padding: var(--space-5) var(--space-4);
        padding-bottom: calc(var(--bottom-nav-height) + var(--space-6));
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .compare-container {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: var(--space-6);
    }

    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }

    .messages-container {
        left: var(--space-4);
        right: var(--space-4);
    }

    .alert {
        min-width: auto;
        max-width: 100%;
    }

    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }

    .photo-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-2);
    }

    .stat-value {
        font-size: var(--font-size-xl);
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .flex.justify-end {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    left: auto;
    z-index: var(--z-overlay);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }
    
    .global-hover-tooltip {
        display: none !important;
    }
}

/* Sidebar overlay on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: calc(var(--z-sticky) - 1);
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Selection ---- */
::selection {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

/* ---- Focus ---- */
:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
}

/* ---- Print ---- */
@media print {
    .sidebar,
    .bottom-nav,
    .mobile-menu-toggle,
    .toast-container,
    .messages-container {
        display: none !important;
    }

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

/* ---- Lightbox ---- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.lightbox.show {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: transform var(--transition-spring);
}

.lightbox.show .lightbox-content {
    transform: scale(1);
}

.lightbox-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-lg);
    display: block;
}

.lightbox-close {
    position: fixed;
    top: var(--space-4);
    right: var(--space-6);
    color: rgba(255, 255, 255, 0.95);
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity var(--transition-fast), color var(--transition-fast);
    z-index: 10000;
    line-height: 1;
}

.lightbox-close:hover {
    opacity: 1;
    color: #ffffff;
}

/* ---- Global Hover Tooltip ---- */
.global-hover-tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    box-shadow: var(--shadow-xl);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.global-hover-tooltip.show {
    opacity: 1;
    visibility: visible;
}

.global-hover-tooltip img {
    max-width: 250px;
    max-height: 250px;
    border-radius: var(--radius-md);
    display: block;
    object-fit: cover;
}
