/**
 * SVN Monitor Public - Mobile-First Styles
 * Design identisch zum lokalen SVN Monitor
 */

/* ============================================================================
   CSS Variables - Identisch zum Original
   ============================================================================ */

:root {
    /* Hintergrundfarben */
    --bg-primary: #0a0f1a;
    --bg-secondary: #0f1520;
    --bg-tertiary: #141c2a;
    --bg-card: #161f30;
    --bg-hover: #1a2438;
    
    /* Akzentfarben */
    --accent-primary: #3b82f6;
    --accent-secondary: #60a5fa;
    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    
    /* Textfarben */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Rahmen */
    --border-color: #1e293b;
    --border-light: #334155;
    
    /* Schatten */
    --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 15px rgba(0, 0, 0, 0.5);
    
    /* Abstände */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Safe Areas für iPhone */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================================================
   Base Styles
   ============================================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ============================================================================
   PIN Screen - iPhone Style
   ============================================================================ */

.modal {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + var(--safe-top));
    z-index: 1000;
}

.pin-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 320px;
}

.pin-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.pin-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.pin-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.pin-dots {
    display: flex;
    gap: 20px;
    margin-bottom: var(--spacing-lg);
}

.pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    background: transparent;
    transition: all 0.15s ease;
}

.pin-dot.filled {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.pin-dot.error {
    border-color: var(--accent-danger);
    background: var(--accent-danger);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.pin-error {
    color: var(--accent-danger);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
    min-height: 1.25rem;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 80px);
    gap: 16px;
    justify-content: center;
}

.pin-key {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.pin-key:active {
    background: var(--accent-primary);
    transform: scale(0.95);
}

.pin-key-empty {
    background: transparent;
    cursor: default;
}

.pin-key-empty:active {
    background: transparent;
    transform: none;
}

.pin-key-delete {
    font-size: 1.5rem;
    background: transparent;
    color: var(--text-secondary);
}

.pin-key-delete:active {
    background: var(--bg-hover);
}

/* Legacy Login Form Styles (für Fallback) */
.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.error-message {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-danger);
    border-radius: var(--radius-sm);
    color: var(--accent-danger);
    font-size: 0.875rem;
    text-align: center;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-secondary);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-icon svg {
    width: 24px;
    height: 24px;
}

/* ============================================================================
   App Header
   ============================================================================ */

.app-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + var(--safe-top));
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.last-update {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

/* ============================================================================
   Pull to Refresh
   ============================================================================ */

.pull-indicator {
    position: fixed;
    top: calc(60px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--bg-card);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 50;
}

.pull-indicator.visible {
    transform: translateX(-50%) translateY(10px);
    opacity: 1;
}

.pull-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================================================
   Main Content
   ============================================================================ */

.main-content {
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-xl) + var(--safe-bottom));
    max-width: 600px;
    margin: 0 auto;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) 0;
    gap: var(--spacing-md);
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.error-state {
    text-align: center;
    padding: var(--spacing-xl) 0;
    color: var(--text-secondary);
}

.error-state p {
    margin-bottom: var(--spacing-md);
    font-size: 1.125rem;
}

/* ============================================================================
   Stats Cards
   ============================================================================ */

.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-card.primary {
    background: linear-gradient(135deg, var(--accent-primary), #2563eb);
    border: none;
}

.stat-card.primary .stat-label {
    color: rgba(255, 255, 255, 0.8);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

/* ============================================================================
   Cards
   ============================================================================ */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border-color);
}

.card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

/* ============================================================================
   Week Chart
   ============================================================================ */

.week-chart {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 100px;
    gap: var(--spacing-xs);
}

.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.bar-item .bar {
    width: 100%;
    max-width: 36px;
    background: var(--accent-primary);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    min-height: 4px;
    transition: height 0.3s ease;
}

.bar-item.today .bar {
    background: linear-gradient(to top, var(--accent-primary), var(--accent-success));
}

.bar-item .bar-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.bar-item .bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================================================
   Commits List
   ============================================================================ */

.commits-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.commit-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

.commit-item:last-child {
    border-bottom: none;
}

.commit-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 45px;
    padding-top: 2px;
}

.commit-content {
    flex: 1;
    min-width: 0;
}

.commit-message {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.commit-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.commit-author {
    color: var(--accent-secondary);
}

.commit-project {
    color: var(--text-secondary);
}

.no-commits {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-muted);
}

/* ============================================================================
   Stats List (Teams & Authors)
   ============================================================================ */

.stats-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.stats-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.stats-item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-item-name {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.stats-item-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stats-item-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.stats-item-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.no-data {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============================================================================
   Filter Tabs & Section Header
   ============================================================================ */

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.section-header h3 {
    margin-bottom: 0;
}

.filter-tabs {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius-md);
}

.filter-tab {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab.active {
    background: var(--accent-primary);
    color: white;
}

.filter-tab:not(.active):hover {
    color: var(--text-primary);
}

/* ============================================================================
   Commits by Repository
   ============================================================================ */

.commits-by-repo {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.repo-group {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.repo-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
}

.repo-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.repo-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.repo-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.repo-commits {
    padding: var(--spacing-sm) 0;
}

.commit-item-new {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.commit-item-new:last-child {
    border-bottom: none;
}

.commit-time-badge {
    font-size: 0.65rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.commit-details {
    flex: 1;
    min-width: 0;
}

.commit-author-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.commit-author-name .team-badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    margin-left: var(--spacing-xs);
    color: white;
    opacity: 0.9;
}

.commit-message-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.no-commits-message {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.commits-section .card {
    padding-bottom: var(--spacing-sm);
}

/* ============================================================================
   Utilities
   ============================================================================ */

/* Prevent overscroll bounce on iOS */
html, body {
    overscroll-behavior: none;
}

/* Touch highlight removal */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Selection color */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: var(--radius-full);
}

/* ============================================================================
   Media Queries
   ============================================================================ */

/* Larger phones */
@media (min-width: 400px) {
    .stat-value {
        font-size: 2rem;
    }
    
    .stats-cards {
        gap: var(--spacing-md);
    }
}

/* Tablets and larger */
@media (min-width: 768px) {
    .main-content {
        padding: var(--spacing-lg);
    }
    
    .stats-cards {
        gap: var(--spacing-lg);
    }
    
    .stat-card {
        padding: var(--spacing-lg);
    }
    
    .stat-value {
        font-size: 2.5rem;
    }
    
    .card {
        padding: var(--spacing-lg);
    }
}
