/* AgentPilot - Mobile AI Agent Control */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #13131a;
    --bg-card: #1a1a24;
    --bg-elevated: #222230;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border: #2a2a3a;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #0a0a0f 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.phone-frame {
    width: 100%;
    max-width: 390px;
    height: 844px;
    background: var(--bg-primary);
    border-radius: 44px;
    overflow: hidden;
    box-shadow: 
        0 0 0 12px #1a1a24,
        0 25px 50px -12px rgba(0, 0, 0, 0.8),
        0 0 100px rgba(99, 102, 241, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-icons {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.app-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
}

.connection-status.connected .status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    padding: 8px 16px;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-btn .badge {
    position: absolute;
    top: 4px;
    right: 8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.tab-content.active {
    display: block;
}

/* Session Cards */
.session-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.session-card.active-session {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.session-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.agent-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.agent-icon.cursor {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.agent-icon.claude {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.agent-icon.codex {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.session-info {
    flex: 1;
}

.session-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.session-project {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.session-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-status.running {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
}

.session-status.running .pulse {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

.session-status.idle {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

.session-status.waiting {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.session-preview {
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.current-task {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.5;
}

.progress-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 2px;
    transition: width 0.5s ease;
}

.session-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Approval Cards */
.approval-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.approval-card.urgent {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.approval-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.approval-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.approval-info {
    flex: 1;
}

.approval-info h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.approval-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.approval-time {
    font-size: 12px;
    color: var(--text-muted);
}

.approval-details {
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.approval-details p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.file-list {
    list-style: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.file-list li {
    color: var(--danger);
    padding: 4px 0;
}

.file-list li::before {
    content: '• ';
    color: var(--text-muted);
}

.package-name {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--accent-light);
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.approval-actions {
    display: flex;
    gap: 10px;
}

.btn-deny, .btn-approve {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-deny {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.btn-deny:hover {
    background: var(--danger);
    color: white;
}

.btn-approve {
    background: var(--success);
    color: white;
}

.btn-approve:hover {
    filter: brightness(1.1);
}

/* History Items */
.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    border: 1px solid var(--border);
}

.history-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.history-icon.success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.history-icon.cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.history-info {
    flex: 1;
}

.history-info h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.history-info p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.history-stats {
    font-size: 11px;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Session Detail Modal */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 60px;
    background: var(--bg-primary);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.modal.visible {
    transform: translateX(0);
}

.modal.hidden {
    display: none;
}

.modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-light);
    font-size: 14px;
    cursor: pointer;
    padding: 8px;
    margin-left: -8px;
}

.modal-header h2 {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Live Output */
.live-output {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

.output-line {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.output-line .timestamp {
    color: var(--text-muted);
    flex-shrink: 0;
}

.output-line .content {
    color: var(--text-secondary);
    word-break: break-word;
}

.output-line.thinking {
    color: var(--accent-light);
}

.output-line.thinking .content {
    color: var(--accent-light);
}

.typing-indicator {
    display: inline-flex;
    gap: 3px;
    margin-left: 8px;
}

.typing-indicator span {
    width: 4px;
    height: 4px;
    background: var(--accent);
    border-radius: 50%;
    animation: typing 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.quick-btn {
    flex: 1;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Prompt Input */
.prompt-input {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0 12px;
}

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    padding: 12px 0;
    outline: none;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.voice-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.voice-btn:hover {
    opacity: 1;
}

.voice-btn.listening {
    opacity: 1;
    animation: pulse 0.5s ease-in-out infinite;
}

.send-btn {
    padding: 12px 20px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--accent-light);
}

/* Toast */
.toast {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 200;
    transition: all 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.toast-icon {
    color: var(--success);
}

.toast-message {
    font-size: 14px;
    color: var(--text-primary);
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    padding: 8px 20px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.nav-btn.active {
    color: var(--accent);
}

.nav-icon {
    font-size: 20px;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
}

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

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

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

/* Responsive */
@media (max-width: 420px) {
    body {
        padding: 0;
    }
    
    .phone-frame {
        border-radius: 0;
        height: 100vh;
        max-width: 100%;
        box-shadow: none;
    }
}
