/* ============================================
   Synx — Apple-style Design System v4
   ============================================ */

:root {
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.06);
    --card-shadow-hover: rgba(0, 0, 0, 0.12);
    --primary: #007AFF;
    --primary-hover: #0062cc;
    --primary-gradient: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    --primary-light: rgba(0, 122, 255, 0.08);
    --primary-medium: rgba(0, 122, 255, 0.15);
    --green: #34C759;
    --green-bg: rgba(52, 199, 89, 0.1);
    --red: #FF3B30;
    --red-bg: rgba(255, 59, 48, 0.1);
    --orange: #FF9500;
    --orange-bg: rgba(255, 149, 0, 0.1);
    --gray: #8E8E93;
    --gray-light: #C7C7CC;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --text-tertiary: #AEAEB2;
    --divider: rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --header-bg: rgba(255, 255, 255, 0.72);
    --log-bg: #1D1D1F;
    --log-text: #E5E5EA;
    --transition: 0.3s ease;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.47;
}

/* ============================================
   Header
   ============================================ */
.header {
    position: sticky; top: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--divider);
}
.header-content {
    max-width: 960px; margin: 0 auto;
    padding: 12px 24px;
    display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 28px; height: 28px; color: var(--primary); }
.logo h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }

.header-right { display: flex; align-items: center; gap: 16px; }
.header-status { display: flex; align-items: center; }

.peers-inline { display: flex; gap: 10px; }
.peer-chip {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 500; color: var(--text-secondary);
    padding: 4px 10px; border-radius: 50px;
    background: var(--bg);
}
.peer-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
    transition: background var(--transition);
}
.peer-dot.online { background: var(--green); animation: pulse 2s infinite; }
.peer-dot.offline { background: var(--gray); }

.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
    display: inline-block; transition: background var(--transition);
}
.status-dot.online { background: var(--green); animation: pulse 2s infinite; }
.status-dot.offline { background: var(--gray); }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(52, 199, 89, 0); }
}

/* ============================================
   Main
   ============================================ */
.main {
    flex: 1; max-width: 960px; width: 100%;
    margin: 0 auto; padding: 20px 24px 80px;
    display: flex; flex-direction: column; gap: 16px;
}

/* ============================================
   Sync Bar
   ============================================ */
.sync-bar {
    display: flex; align-items: center; justify-content: center; gap: 16px;
}
.sync-bar-info {
    font-size: 13px; color: var(--text-tertiary); font-weight: 500;
    min-width: 140px; text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sync-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 9px 18px; border: none; border-radius: 50px;
    background: var(--primary-gradient); color: #fff;
    font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.sync-btn:hover:not(:disabled) { transform: scale(1.04); box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35); }
.sync-btn:active:not(:disabled) { transform: scale(0.97); }
.sync-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-arrow { width: 16px; height: 16px; }

/* ============================================
   Search
   ============================================ */
.search-section { position: relative; }
.search-box {
    display: flex; align-items: center; gap: 10px;
    background: var(--card-bg); border-radius: var(--radius-sm);
    padding: 10px 16px;
    box-shadow: 0 1px 3px var(--card-shadow), 0 0 0 1px var(--divider);
    transition: box-shadow 0.2s ease;
}
.search-box:focus-within {
    box-shadow: 0 1px 3px var(--card-shadow), 0 0 0 2px var(--primary);
}
.search-icon { color: var(--text-tertiary); flex-shrink: 0; }
.search-box input {
    flex: 1; border: none; outline: none; background: transparent;
    font-family: var(--font); font-size: 14px; color: var(--text-primary);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-count {
    font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; font-variant-numeric: tabular-nums;
}

/* ============================================
   Projects
   ============================================ */
.projects-section { display: flex; flex-direction: column; }
.projects-list {
    background: var(--card-bg); border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--card-shadow), 0 0 0 1px var(--divider);
    overflow: hidden;
    max-height: calc(100vh - 340px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,0.1) transparent;
}
.projects-list::-webkit-scrollbar { width: 6px; }
.projects-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
.projects-empty {
    padding: 48px 24px; text-align: center;
    font-size: 14px; color: var(--text-tertiary);
}

/* Favorites separator */
.projects-separator {
    padding: 6px 20px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-tertiary);
    background: var(--bg);
    border-bottom: 1px solid var(--divider);
}

/* Project Row */
.project-row {
    display: flex; align-items: center;
    padding: 12px 20px; gap: 12px;
    cursor: pointer; transition: all 0.15s ease;
    border-bottom: 1px solid var(--divider);
    position: relative;
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: rgba(0, 0, 0, 0.02); }
.project-row.active { background: rgba(0, 122, 255, 0.06); }
.project-row.active::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--primary); border-radius: 0 3px 3px 0;
}
.project-row.dimmed { opacity: 0.4; }
.project-row.hidden { display: none; }

/* Favorite star */
.project-star {
    width: 28px; height: 28px; border: none; background: transparent;
    cursor: pointer; font-size: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: all 0.15s ease;
    color: var(--text-tertiary);
}
.project-star:hover { background: rgba(255, 204, 0, 0.15); }
.project-star.favorited { color: #FFB800; }

/* Sync status icon */
.project-sync-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.project-sync-icon.synced { background: var(--green-bg); }
.project-sync-icon.different { background: var(--orange-bg); }
.project-sync-icon.unknown { background: rgba(142, 142, 147, 0.1); }
.project-sync-icon.one_side { background: rgba(142, 142, 147, 0.1); }

/* Project info */
.project-info { flex: 1; min-width: 0; }
.project-name {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-meta {
    font-size: 11px; color: var(--text-tertiary); margin-top: 1px;
    display: flex; gap: 8px;
}
.project-meta .tag {
    padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.tag.home { background: rgba(0, 122, 255, 0.08); color: var(--primary); }
.tag.work { background: rgba(88, 86, 214, 0.08); color: #5856D6; }
.tag.only { background: var(--orange-bg); color: var(--orange); }

/* Status badge */
.project-status {
    display: flex; flex-direction: column; align-items: flex-end;
    flex-shrink: 0; gap: 1px;
}
.project-status-label { font-size: 11px; font-weight: 600; }
.project-status-label.synced { color: var(--green); }
.project-status-label.different { color: var(--orange); }
.project-status-label.unknown { color: var(--gray); }
.project-status-label.one_side { color: var(--gray); }
.project-status-detail { font-size: 10px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

/* ============================================
   Progress
   ============================================ */
.progress-section {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: 0 1px 3px var(--card-shadow), 0 0 0 1px var(--divider);
}
.progress-header { display: flex; justify-content: space-between; margin-bottom: 10px; }
.progress-title { font-size: 14px; font-weight: 600; }
.progress-pct { font-size: 13px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.progress-bar { width: 100%; height: 6px; background: var(--divider); border-radius: 3px; overflow: hidden; }
.progress-fill {
    height: 100%; border-radius: 3px; background: var(--primary-gradient);
    transition: width 0.5s ease; position: relative;
}
.progress-fill::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.progress-message { margin-top: 8px; font-size: 12px; color: var(--text-secondary); }

/* ============================================
   Log — Collapsible
   ============================================ */
.log-section { display: flex; flex-direction: column; }
.log-header {
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; user-select: none; padding: 6px 0;
}
.log-header h3 { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.log-header-right { display: flex; align-items: center; gap: 8px; }
.log-chevron { color: var(--text-tertiary); transition: transform 0.2s ease; }
.log-chevron.open { transform: rotate(180deg); }
.log-clear-btn {
    border: none; background: none; color: var(--primary);
    font-family: var(--font); font-size: 12px; font-weight: 500;
    cursor: pointer; padding: 3px 8px; border-radius: var(--radius-xs);
    transition: background var(--transition);
}
.log-clear-btn:hover { background: var(--primary-light); }
.log-container {
    background: var(--log-bg); border-radius: var(--radius-sm);
    padding: 14px; max-height: 180px; overflow-y: auto;
    display: flex; flex-direction: column; gap: 3px; margin-top: 6px;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.log-container::-webkit-scrollbar { width: 6px; }
.log-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.log-entry { font-family: var(--font-mono); font-size: 11px; line-height: 1.6; display: flex; gap: 8px; }
.log-time { color: rgba(255,255,255,0.3); flex-shrink: 0; }
.log-msg { word-break: break-word; }
.log-entry.info .log-msg { color: var(--log-text); }
.log-entry.success .log-msg { color: var(--green); }
.log-entry.error .log-msg { color: var(--red); }
.log-entry.progress .log-msg { color: var(--primary); }

/* ============================================
   Status Bar
   ============================================ */
.status-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--divider);
}
.status-bar-content {
    max-width: 960px; margin: 0 auto; padding: 8px 24px;
    display: flex; align-items: center; justify-content: space-between;
    font-size: 11px; color: var(--text-tertiary);
}

/* ============================================
   Update Button & Modal
   ============================================ */
.update-btn {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--font); font-size: 12px; font-weight: 500;
    padding: 5px 12px; border: none; border-radius: 50px;
    background: var(--primary-light); color: var(--primary);
    cursor: pointer; transition: all 0.2s ease;
}
.update-btn:hover { background: var(--primary-medium); }
.update-btn:active { transform: scale(0.97); }

.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 28px; width: 100%; max-width: 360px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.3px; }
.modal-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }
.modal-buttons { display: flex; gap: 10px; margin-bottom: 20px; }
.modal-peer-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 16px; border: 2px solid var(--divider); border-radius: var(--radius-sm);
    background: var(--card-bg); font-family: var(--font); font-size: 14px; font-weight: 600;
    color: var(--text-primary); cursor: pointer; transition: all 0.2s ease;
}
.modal-peer-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.modal-peer-btn:active { transform: scale(0.97); }
.modal-peer-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.modal-actions { display: flex; justify-content: flex-end; }
.modal-btn {
    padding: 8px 18px; border: none; border-radius: 50px;
    font-family: var(--font); font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
}
.modal-btn.cancel { background: var(--bg); color: var(--text-secondary); }
.modal-btn.cancel:hover { background: var(--divider); }

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 700px) {
    .sync-bar { flex-direction: column; gap: 8px; }
    .peers-inline { gap: 6px; }
    .header-content { padding: 10px 16px; }
    .main { padding: 14px 16px 80px; }
    .project-meta { flex-wrap: wrap; }
}

/* ===== Tools bar (Maven / Docker) ===== */
.tools-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 3px var(--card-shadow), 0 0 0 1px var(--divider);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow .15s, transform .1s, opacity .15s;
}
.tool-btn svg { color: var(--primary); flex-shrink: 0; }
.tool-btn:hover:not(:disabled) { box-shadow: 0 2px 8px var(--card-shadow-hover), 0 0 0 1px var(--primary); transform: translateY(-1px); }
.tool-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===== Docker modal ===== */
.modal-wide { max-width: 560px; width: 92%; }
.docker-source-row {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 12px; flex-wrap: wrap;
}
.docker-label, .docker-dest-label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.docker-src-btn {
    padding: 6px 12px; border-radius: var(--radius-xs);
    border: none; background: var(--bg); color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--divider); font-family: var(--font);
    font-size: 13px; cursor: pointer;
}
.docker-src-btn.active { background: var(--primary-light); box-shadow: 0 0 0 1px var(--primary); color: var(--primary); font-weight: 600; }
.docker-list {
    max-height: 320px; overflow-y: auto;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 1px var(--divider) inset;
    padding: 6px;
    margin-bottom: 14px;
}
.docker-empty { padding: 24px 12px; text-align: center; color: var(--text-tertiary); font-size: 13px; }
.docker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-xs);
    cursor: pointer;
}
.docker-row:hover { background: var(--bg); }
.docker-row input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.docker-name { flex: 1; font-size: 13px; color: var(--text-primary); word-break: break-all; }
.docker-size { font-size: 12px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.modal-btn.primary { background: var(--primary-gradient); color: #fff; }
.modal-btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.modal-actions { gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== Maven sync status ===== */
.maven-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    margin-left: 2px;
}
.maven-status:empty { display: none; }
.maven-status.syncing {
    color: #FF9500;
    background: rgba(255, 149, 0, 0.12);
}
.maven-status.synced {
    color: #34C759;
    background: rgba(52, 199, 89, 0.12);
}
