/* ===========================
   CSS Variables & Reset
   =========================== */
:root {
    --bg:         #0d0d0d;
    --bg-card:    #1a1a1a;
    --bg-input:   #222222;
    --border:     #2a2a2a;
    --text:       #e0e0e0;
    --text-muted: #888888;
    --accent:     #6366f1;
    --accent-dim: #6366f120;
    --success:    #22c55e;
    --error:      #ef4444;
    --warning:    #f59e0b;
    --radius:     12px;
    --radius-sm:  8px;
    --safe-top:   env(safe-area-inset-top, 0px);
    --safe-bottom:env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }

/* ===========================
   Login
   =========================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 20px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
}

.login-container {
    width: 100%;
    max-width: 360px;
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-text {
    display: block;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--text);
}

.logo-img {
    display: block;
    height: 48px;
    width: auto;
    margin: 0 auto;
}

.logo-img-sm {
    display: block;
    height: 28px;
    width: auto;
}

.logo-sub {
    display: block;
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

/* ===========================
   Header
   =========================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(13, 13, 13, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: var(--safe-top);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.header-logo { display: flex; align-items: baseline; gap: 8px; }
.header-logo .logo-text { font-size: 18px; font-weight: 800; letter-spacing: 3px; }
.header-logo .logo-img-sm { height: 24px; width: auto; }
.header-logo .logo-sub { font-size: 11px; letter-spacing: 2px; color: var(--text-muted); text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.header-nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
}

.nav-link:hover { color: var(--text); background: var(--bg-input); }
.nav-link--active { color: var(--text); background: var(--bg-input); }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.btn-icon:hover, .btn-icon:active { color: var(--text); background: var(--bg-card); }

/* ===========================
   Main Layout
   =========================== */
.main {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 16px;
    padding-bottom: calc(32px + var(--safe-bottom));
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ===========================
   Project Cards
   =========================== */
.projects-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .projects-grid { grid-template-columns: 1fr 1fr; }
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.2s;
}

.project-card.skeleton { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.6; }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}

.card-icon { font-size: 18px; }

/* Status Dot */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--error); }
.status-dot.error   { background: var(--warning); }
.status-dot.loading { background: var(--border); animation: pulse 1s ease-in-out infinite; }

/* Deploy Info */
.deploy-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.deploy-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.deploy-badge.success { background: #22c55e20; color: var(--success); }
.deploy-badge.failure { background: #ef444420; color: var(--error); }
.deploy-badge.running { background: #6366f120; color: var(--accent); animation: pulse 1s infinite; }
.deploy-badge.queued  { background: #f59e0b20; color: var(--warning); }
.deploy-badge.none    { background: var(--bg-input); color: var(--text-muted); }

.deploy-time { color: var(--text-muted); font-size: 12px; }
.loading-text { color: var(--text-muted); font-size: 13px; }

/* Card Footer */
.card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); background: var(--bg-input); }

.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-full { width: 100%; }

/* ===========================
   Input
   =========================== */
.input-group input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 16px;
    padding: 14px 16px;
    outline: none;
    transition: border-color 0.15s;
}

.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-muted); }

/* ===========================
   Alert
   =========================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error { background: #ef444420; color: var(--error); border: 1px solid #ef444430; }

/* ===========================
   Modal
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0 0 var(--safe-bottom);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 480px;
    transform: translateY(20px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-icon { font-size: 24px; }
.modal-title { font-size: 18px; font-weight: 700; }
.modal-text { color: var(--text-muted); margin-bottom: 24px; font-size: 15px; }
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; padding: 14px; }

/* ===========================
   Toast
   =========================== */
.toast {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    z-index: 300;
    white-space: nowrap;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--error); color: var(--error); }

/* ===========================
   Refresh Animation
   =========================== */
.btn-icon.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===========================
   Git Push Status
   =========================== */
.git-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 2rem;
}

.git-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}
.git-hint svg { flex-shrink: 0; margin-top: 2px; }
.git-hint code { background: rgba(255,255,255,0.08); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.git-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s;
}
.git-row.skeleton { opacity: 0.5; }

.git-row__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.git-row__name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
}

.git-row__badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.git-row__badge.ok      { background: rgba(34,197,94,0.15); color: var(--success); }
.git-row__badge.warn    { background: rgba(234,179,8,0.15);  color: #eab308; }
.git-row__badge.fail    { background: rgba(239,68,68,0.15);  color: var(--error); }
.git-row__badge.running { background: rgba(99,102,241,0.15); color: #818cf8; }
.git-row__badge.none    { background: rgba(255,255,255,0.05); color: var(--text-muted); }

.git-row__commits {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.git-commit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}
.git-label {
    color: var(--text-muted);
    min-width: 80px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.git-sha {
    background: rgba(255,255,255,0.07);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    letter-spacing: 0.05em;
}
.git-sha--warn { background: rgba(234,179,8,0.12); color: #eab308; }
.git-msg { color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.git-time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.git-hint-inline { font-size: 11px; color: #eab308; }

.git-row__cmd {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
}
.git-cmd {
    flex: 1;
    font-family: monospace;
    font-size: 12px;
    color: #a5f3fc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
}
.btn-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.btn-copy:hover  { color: var(--text); background: rgba(255,255,255,0.07); }
.btn-copy.copied { color: var(--success); }

/* ── Mobile Header (≤ 480px) ─────────────────────────── */
@media (max-width: 480px) {
    .logo-sub { display: none; }

    .header-inner { padding: 10px 14px; }

    .nav-link {
        padding: 6px 8px;
        font-size: 11px;
        gap: 4px;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
    }
}
