/* ========================================
   OpenClaw Admin - Mobile First Dark Theme
   ======================================== */

/* CSS Variables */
:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border-color: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-primary: #58a6ff;
    --accent-secondary: #388bfd;
    --success: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
    --info: #58a6ff;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

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

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-screen p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* App Container */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app.hidden {
    display: none;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    padding-bottom: calc(0.75rem + env(safe-area-inset-top));
    padding-top: calc(0.75rem + env(safe-area-inset-top));
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

.last-update {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Navigation Drawer */
.nav-drawer {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
    visibility: hidden;
}

.nav-drawer.open {
    pointer-events: auto;
    visibility: visible;
}

.nav-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-drawer.open .nav-drawer-backdrop {
    opacity: 1;
}

.nav-drawer-content {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-secondary);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.nav-drawer.open .nav-drawer-content {
    transform: translateX(0);
}

.nav-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.nav-avatar {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.nav-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.nav-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.nav-list {
    list-style: none;
    padding: 1rem 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

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

.nav-item.active {
    border-left: 3px solid var(--accent-primary);
}

.nav-icon {
    font-size: 1.25rem;
}

.nav-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.version {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1rem;
    padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-icon {
    font-size: 1.75rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.info-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.info-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.info-value {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Resource Usage */
.resource-item {
    margin-bottom: 1rem;
}

.resource-item:last-child {
    margin-bottom: 0;
}

.resource-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.cpu {
    background: linear-gradient(90deg, var(--info), var(--accent-primary));
}

.progress-fill.memory {
    background: linear-gradient(90deg, var(--warning), #e3b341);
}

.progress-fill.disk {
    background: linear-gradient(90deg, var(--success), #4ade80);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

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

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Project List */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--transition);
}

.project-card:active {
    transform: scale(0.98);
}

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

.project-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-path {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    word-break: break-all;
}

.project-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.project-status.clean {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.project-status.dirty {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
}

.project-status.ahead {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

.project-stats {
    display: flex;
    gap: 1rem;
}

.project-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.project-branch {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--accent-primary);
    margin-top: 0.5rem;
}

/* Cron List */
.cron-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.cron-stat {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.cron-stat-value {
    font-size: 2rem;
    font-weight: 700;
    display: block;
}

.cron-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cron-stat.enabled .cron-stat-value {
    color: var(--success);
}

.cron-stat.disabled .cron-stat-value {
    color: var(--text-muted);
}

.cron-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cron-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--transition);
}

.cron-card:active {
    transform: scale(0.98);
}

.cron-card.disabled {
    opacity: 0.6;
}

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

.cron-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.cron-toggle {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.cron-toggle.enabled {
    background: var(--success);
}

.cron-toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
}

.cron-toggle.enabled::after {
    left: 22px;
}

.cron-schedule {
    font-size: 0.875rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    font-family: 'SF Mono', Monaco, monospace;
}

.cron-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cron-next {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cron-next::before {
    content: '⏱';
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--accent-secondary);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
    z-index: 100;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    min-width: 64px;
}

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

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

.bottom-nav-label {
    font-size: 0.625rem;
    font-weight: 500;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

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

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

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

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

/* Media Queries - Tablet & Desktop */
@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .main-content {
        max-width: 1024px;
        margin: 0 auto;
        padding-bottom: 1rem;
    }

    .bottom-nav {
        display: none;
    }

    .card-body {
        padding: 1.25rem;
    }

    .project-card:hover, .cron-card:hover {
        border-color: var(--accent-primary);
    }
}

@media (min-width: 1024px) {
    .header {
        padding: 1rem 2rem;
    }

    .main-content {
        padding: 1.5rem 2rem;
    }

    .section-header {
        margin-bottom: 1.5rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }
}

/* PWA Manifest Placeholder */
.manifest-placeholder {
    display: none;
}
