/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --brand: #667eea;
    --brand-dark: #5568d3;
    --accent: #764ba2;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6c757d;
    --border: #e2e8f0;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: 56px;
    box-shadow: var(--shadow);
}
.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand);
    margin-right: 32px;
    white-space: nowrap;
}
.nav-links {
    display: flex;
    gap: 4px;
}
.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    margin-left: auto;
    padding: 8px;
}
.nav-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}
.nav-mobile {
    display: none;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px;
}
.nav-mobile.open { display: flex; }
.nav-mobile .nav-link { padding: 12px 16px; }

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* ─── View Header ─────────────────────────────────────────────────────────── */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.view-header h1 {
    font-size: 24px;
    font-weight: 700;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(102,126,234,0.4); }
.btn-primary:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-danger {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}
.btn-danger:hover { background: #dc2626; }
.btn-back {
    background: none;
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    transition: all 0.15s;
}
.btn-back:hover { background: var(--bg); }
.btn-icon {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); }

/* ─── Filter Bar ──────────────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.filter-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: border-color 0.15s;
}
.filter-input:focus { outline: none; border-color: var(--brand); }
.filter-select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    min-width: 140px;
}
.filter-select:focus { outline: none; border-color: var(--brand); }
.gallery-count {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ─── Gallery Grid ────────────────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.gallery-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    display: block;
}
.gallery-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.gallery-card-img {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg);
    overflow: hidden;
}
.gallery-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, #f0f2f5, #e2e8f0);
}
.wear-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0,0,0,0.6);
    color: #fff;
}
.wear-badge.wear-high { background: #22c55e; color: #fff; }
.wear-badge.wear-mid { background: var(--brand); color: #fff; }
.wear-badge.wear-low { background: rgba(0,0,0,0.5); }
.wear-badge.wear-none { background: rgba(0,0,0,0.25); }
.gallery-card-body { padding: 12px; }
.gallery-card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-card-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.type-badge {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.color-dot { font-size: 11px; color: var(--text-secondary); }
.gallery-card-brand { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Tags ────────────────────────────────────────────────────────────────── */
.tag {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
    margin-bottom: 4px;
}
.detail-tags { margin-top: 12px; }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s;
}
.modal-box {
    background: var(--surface);
    border-radius: 12px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-lg);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { font-size: 20px; }
.modal-close { background: none; border: none; font-size: 28px; color: var(--text-secondary); line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand);
}

/* ─── Item Detail ─────────────────────────────────────────────────────────── */
.detail-layout { display: grid; grid-template-columns: 400px 1fr; gap: 32px; margin-bottom: 32px; }
.detail-photo { border-radius: var(--radius); overflow: hidden; background: var(--bg); aspect-ratio: 1; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-photo-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 80px; }
.detail-info h1 { font-size: 28px; margin-bottom: 12px; }
.detail-wear-count {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: #fff;
    padding: 8px 20px;
    border-radius: 24px;
    margin-bottom: 20px;
}
.wear-count-num { font-size: 28px; font-weight: 800; }
.wear-count-label { font-size: 14px; opacity: 0.9; }
.detail-meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.detail-meta { background: var(--bg); padding: 10px 14px; border-radius: 8px; }
.meta-label { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.meta-value { font-size: 15px; font-weight: 500; }

/* ─── Wear History ────────────────────────────────────────────────────────── */
.detail-history { margin-top: 8px; }
.detail-history h2 { font-size: 18px; margin-bottom: 16px; }
.history-list { display: grid; gap: 10px; }
.history-card { background: var(--surface); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.history-date { font-weight: 600; margin-bottom: 4px; }
.history-occasion { font-size: 13px; color: var(--brand); font-weight: 500; margin-bottom: 6px; }
.history-items { display: flex; flex-wrap: wrap; gap: 6px; }
.history-item-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
}
.history-item-pill.current { background: var(--brand); color: #fff; }
.history-item-pill.clickable { cursor: pointer; transition: background 0.15s; }
.history-item-pill.clickable:hover { background: var(--brand); color: #fff; }
.pill-avatar { width: 20px; height: 20px; border-radius: 4px; object-fit: cover; }
.history-notes { margin-top: 6px; font-size: 13px; color: var(--text-secondary); font-style: italic; }

/* ─── Calendar ────────────────────────────────────────────────────────────── */
.cal-nav { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 20px; }
.cal-nav h2 { font-size: 20px; min-width: 200px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 24px; }
.cal-header { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 8px 0; }
.cal-cell {
    background: var(--surface);
    border-radius: 8px;
    min-height: 60px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.cal-cell.empty { background: transparent; cursor: default; }
.cal-cell:not(.empty):hover { box-shadow: var(--shadow); }
.cal-cell.today { border: 2px solid var(--brand); }
.cal-cell.selected { background: #eef2ff; box-shadow: inset 0 0 0 2px var(--brand); }
.cal-cell.has-log { background: #f0fdf4; }
.cal-cell.has-log.selected { background: #dcfce7; }
.cal-day { font-size: 14px; font-weight: 500; }
.cal-dots { display: flex; gap: 3px; margin-top: 4px; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.cal-detail { background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.cal-detail h3 { margin-bottom: 12px; }

/* ─── Log Outfit ──────────────────────────────────────────────────────────── */
.log-form-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.log-picker { display: grid; gap: 16px; }
.picker-group h3 { font-size: 15px; margin-bottom: 10px; }
.picker-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.picker-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.picker-card:hover { border-color: var(--brand); }
.picker-card.selected { border-color: var(--brand); background: #eef2ff; }
.picker-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.picker-img-placeholder { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 32px; background: var(--bg); border-radius: 6px; margin-bottom: 6px; }
.picker-name { font-size: 12px; font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-check { position: absolute; top: 6px; right: 6px; background: var(--brand); color: #fff; width: 22px; height: 22px; border-radius: 50%; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.log-sidebar {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: sticky;
    top: 80px;
}
.selected-summary { margin-bottom: 16px; }
.selected-summary h3 { font-size: 15px; margin-bottom: 8px; }
.empty-hint { font-size: 13px; color: var(--text-secondary); }
.selected-pill {
    display: inline-flex;
    align-items: center;
    background: var(--brand);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    margin: 2px 4px 2px 0;
    cursor: pointer;
}
.selected-pill:hover { background: var(--brand-dark); }

/* ─── Stats ───────────────────────────────────────────────────────────────── */
.stats-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.stat-num { font-size: 32px; font-weight: 800; color: var(--brand); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stats-panel { background: var(--surface); padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.stats-panel h3 { font-size: 16px; margin-bottom: 16px; }
.top-items-list { display: grid; gap: 8px; }
.top-item-row {
    display: grid;
    grid-template-columns: 40px 1fr auto 80px;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 8px;
    transition: background 0.15s;
}
.top-item-row:hover { background: var(--bg); }
.top-item-avatar { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.top-item-avatar-placeholder { width: 40px; height: 40px; border-radius: 8px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 20px; }
.top-item-name { font-size: 14px; font-weight: 500; }
.top-item-type { font-size: 11px; color: var(--text-secondary); }
.top-item-count { font-size: 14px; font-weight: 700; color: var(--brand); text-align: right; }
.top-item-bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.top-item-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 3px; transition: width 0.3s; }

/* ─── Shared ──────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-secondary); }
.loading { text-align: center; padding: 60px; color: var(--text-secondary); font-size: 16px; }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    animation: slideIn 0.2s;
}
.toast.success { background: #22c55e; color: #fff; }
.toast.error { background: #ef4444; color: #fff; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .nav-links { display: none; }
    .nav-menu-btn { display: flex; }
    .detail-layout { grid-template-columns: 1fr; }
    .detail-photo { max-height: 300px; aspect-ratio: auto; }
    .log-form-layout { grid-template-columns: 1fr; }
    .log-sidebar { position: static; }
    .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .main-content { padding: 16px; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .form-row { grid-template-columns: 1fr; }
    .view-header h1 { font-size: 20px; }
    .picker-items { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

/* ─── Auth Pages ──────────────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}
.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.auth-card h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--brand);
    margin-bottom: 4px;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 8px;
    padding: 4px;
}
.auth-tabs button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.15s;
}
.auth-tabs button.active {
    background: var(--surface);
    color: var(--brand);
    box-shadow: var(--shadow);
}
.auth-form { text-align: left; }
.auth-form .form-group { margin-bottom: 14px; }
.auth-error {
    color: #ef4444;
    font-size: 13px;
    margin-top: 10px;
    text-align: center;
}
.auth-skip {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.btn-link {
    background: none;
    border: none;
    color: var(--brand);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }
.btn-sm { font-size: 12px; }

/* ─── Nav User ────────────────────────────────────────────────────────────── */
.nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.nav-login-link {
    margin-left: auto;
}
.nav-mobile-user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}
