/* ══════════════════════════════════════════════════════
 *  MilkTunnel — Dashboard Styles
 *  Extracted from inline <style> for CF-friendly caching.
 * ══════════════════════════════════════════════════════ */

/* ── Login Screen ────────────────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    background: #0f1117;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    transition: opacity 0.3s;
}

.login-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 380px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f0f6fc;
    margin-bottom: 0.35rem;
}

.login-card .login-subtitle {
    font-size: 0.82rem;
    color: #8b949e;
    margin-bottom: 1.5rem;
}

.login-card .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.login-card input[type="password"] {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.55rem 0.7rem;
    color: #c9d1d9;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}

.login-card input[type="password"]:focus {
    border-color: #58a6ff;
}

.login-card .login-btn {
    width: 100%;
    margin-top: 0.5rem;
}

.login-error {
    font-size: 0.8rem;
    color: #f85149;
    margin-top: 0.75rem;
    min-height: 1.2em;
}

/* ── Dashboard Layout ────────────────────────────────── */
.dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dash-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.dash-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f0f6fc;
}

.dash-header .subtitle {
    color: #8b949e;
    font-size: 0.82rem;
    margin: 0;
}

/* ── Project Grid ────────────────────────────────────── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.project-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 1.25rem;
    transition: border-color 0.2s;
}

.project-card:hover {
    border-color: #484f58;
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.project-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #f0f6fc;
    word-break: break-word;
}

.project-id {
    font-size: 0.72rem;
    color: #484f58;
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.project-repo {
    font-size: 0.78rem;
    color: #8b949e;
    word-break: break-all;
    margin-bottom: 0.5rem;
    font-family: 'SFMono-Regular', Consolas, monospace;
}

.project-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.78rem;
    color: #8b949e;
    margin-bottom: 0.75rem;
}

.project-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ── Status Badge ────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-badge.running        { background: #0d3117; color: #3fb950; }
.status-badge.running .dot   { background: #3fb950; }

.status-badge.building,
.status-badge.cloning         { background: #2d1f00; color: #d29922; }
.status-badge.building .dot,
.status-badge.cloning .dot    { background: #d29922; }

.status-badge.error           { background: #3d1014; color: #f85149; }
.status-badge.error .dot      { background: #f85149; }

.status-badge.stopped         { background: #1c1c1c; color: #8b949e; }
.status-badge.stopped .dot    { background: #8b949e; }

.status-badge.pending         { background: #1c1c2e; color: #a78bfa; }
.status-badge.pending .dot    { background: #a78bfa; }

/* ── Project Actions ─────────────────────────────────── */
.project-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #21262d;
}

.project-actions button {
    font-size: 0.75rem;
    padding: 0.3rem 0.65rem;
}

.btn-danger {
    color: #f85149;
    border-color: #f8514933;
}
.btn-danger:hover {
    background: #3d1014;
    border-color: #f85149;
}

.btn-open {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #0d3117;
    color: #3fb950;
    border: 1px solid #23863633;
    border-radius: 6px;
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.btn-open:hover {
    background: #238636;
    border-color: #2ea043;
    color: #fff;
}

/* ── Empty State ─────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #484f58;
}

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

.empty-state h2 {
    font-size: 1.2rem;
    color: #8b949e;
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto 1.5rem;
    line-height: 1.6;
}

/* ── Modal ───────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 480px;
    transform: translateY(10px);
    transition: transform 0.2s;
}

.modal-overlay.open .modal {
    transform: translateY(0);
}

.modal h2 {
    font-size: 1.1rem;
    color: #f0f6fc;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: #8b949e;
    margin-bottom: 0.3rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    color: #c9d1d9;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #58a6ff;
}

.form-group .hint {
    font-size: 0.72rem;
    color: #484f58;
    margin-top: 0.25rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ── Log Drawer ──────────────────────────────────────── */
.log-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #0d1117;
    border-top: 1px solid #30363d;
    z-index: 90;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    max-height: 40vh;
    display: flex;
    flex-direction: column;
}

.log-drawer.open {
    transform: translateY(0);
}

.log-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #21262d;
    flex-shrink: 0;
}

.log-drawer-header h3 {
    font-size: 0.85rem;
    color: #f0f6fc;
}

.log-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: #8b949e;
}

.log-drawer-content .log-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.log-drawer-content .log-line .ts {
    color: #484f58;
    margin-right: 0.5rem;
}

/* ── Files Modal ─────────────────────────────────────── */
.files-tree {
    max-height: 400px;
    overflow-y: auto;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.8;
    color: #8b949e;
}

.files-dir-label {
    color: #484f58;
    font-size: 0.72rem;
    margin-bottom: 0.5rem;
    display: block;
}

.files-entry {
    color: #c9d1d9;
    white-space: nowrap;
}

.files-entry .file-icon {
    color: #8b949e;
    margin-right: 0.35rem;
}

.files-entry.dir-entry {
    color: #58a6ff;
    font-weight: 600;
}

.files-empty {
    color: #484f58;
    text-align: center;
    padding: 2rem;
}

/* ── Connection & Ping Indicators ────────────────────── */
.conn-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: #8b949e;
    padding: 0.2rem 0.6rem;
    background: #21262d;
    border-radius: 6px;
    border: 1px solid #30363d;
}

.conn-indicator.live {
    border-color: #238636;
}

.conn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f85149;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.2);
    transition: background 0.3s, box-shadow 0.3s;
}

.conn-dot.ok {
    background: #3fb950;
    box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.25);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.25); }
    50%      { box-shadow: 0 0 0 4px rgba(63, 185, 80, 0.1); }
}

.metric-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #484f58;
    padding: 0.2rem 0.55rem;
    background: #21262d;
    border-radius: 6px;
    border: 1px solid #30363d;
    font-family: 'SFMono-Regular', Consolas, monospace;
    transition: color 0.2s, border-color 0.2s;
}

.metric-indicator.good { color: #3fb950; border-color: #23863633; }
.metric-indicator.warn { color: #d29922; border-color: #d2992233; }
.metric-indicator.bad  { color: #f85149; border-color: #f8514933; }

/* ── Logout Button ───────────────────────────────────── */
.btn-logout {
    background: none;
    border: 1px solid #30363d;
    color: #8b949e;
    padding: 0.25rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: #21262d;
    color: #c9d1d9;
}

/* ── Toast ────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.8rem;
    color: #c9d1d9;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 3s forwards;
    max-width: 360px;
}

.toast.error {
    border-color: #f85149;
    color: #f85149;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(1rem); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ── Activity Feed ───────────────────────────────────── */
.activity-section {
    margin-top: 2rem;
    border: 1px solid #30363d;
    border-radius: 10px;
    background: #161b22;
    overflow: hidden;
}

.activity-section.collapsed .activity-list {
    display: none;
}

.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #21262d;
}

.activity-header h2 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f0f6fc;
    margin: 0;
}

.btn-small {
    background: none;
    border: 1px solid #30363d;
    color: #8b949e;
    padding: 0.15rem 0.5rem;
    font-size: 0.68rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-small:hover {
    background: #21262d;
}

.activity-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.activity-empty {
    color: #484f58;
    font-size: 0.78rem;
    text-align: center;
    padding: 1.5rem;
}

.activity-entry {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.3rem 1rem;
    font-size: 0.75rem;
    line-height: 1.6;
    border-bottom: 1px solid #21262d0a;
    transition: background 0.1s;
}

.activity-entry:hover {
    background: #1c2128;
}

.activity-entry:last-child {
    border-bottom: none;
}

.activity-time {
    color: #484f58;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.7rem;
    flex-shrink: 0;
    min-width: 5.5em;
}

.activity-category {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    min-width: 4.5em;
    text-align: center;
}

.activity-category.system  { background: #21262d; color: #8b949e; }
.activity-category.deploy  { background: #0d3117; color: #3fb950; }
.activity-category.auth    { background: #1c1c2e; color: #a78bfa; }
.activity-category.webhook { background: #2d1f00; color: #d29922; }
.activity-category.health  { background: #0d2535; color: #58a6ff; }
.activity-category.project { background: #1a1d23; color: #c9d1d9; }
.activity-category.tunnel  { background: #1a0d2e; color: #d2a8ff; }
.activity-category.docker  { background: #0d1f2d; color: #79c0ff; }

.activity-msg {
    color: #c9d1d9;
    word-break: break-word;
}

.activity-entry.warn .activity-msg  { color: #d29922; }
.activity-entry.error .activity-msg { color: #f85149; }

.activity-entry.new {
    animation: activity-flash 0.5s ease;
}

@keyframes activity-flash {
    0%   { background: #1c2128; }
    100% { background: transparent; }
}

/* ── Status Message (inline on card) ─────────────────── */
.project-status-msg {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.project-status-msg.error   { color: #f85149; }
.project-status-msg.warning { color: #d29922; }

/* ── Dockerfile Modal ───────────────────────────────── */
.dockerfile-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dockerfile-tab {
    background: #21262d;
    border: 1px solid #30363d;
    color: #8b949e;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.dockerfile-tab:hover {
    background: #30363d;
    color: #c9d1d9;
}

.dockerfile-tab.active {
    background: #0d419d;
    border-color: #58a6ff;
    color: #f0f6fc;
}

.dockerfile-content {
    max-height: 400px;
    overflow-y: auto;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: #c9d1d9;
    white-space: pre-wrap;
    word-break: break-word;
}

.dockerfile-label {
    color: #58a6ff;
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}

.dockerfile-empty {
    color: #484f58;
    text-align: center;
    padding: 2rem;
}
