/**
 * Ralph Command Center - Stylesheet
 * =================================
 * 
 * Custom-built dashboard for Bram & Ralph
 * Brand color: Accent Blue #58a6ff
 * 
 * Design principles:
 * - Action-focused, not just data display
 * - Clear visual hierarchy
 * - Mobile-first responsive
 * - Less is more
 */

/* ===========================================
   CSS CUSTOM PROPERTIES
   =========================================== */
:root {
    /* Ralph Branding */
    --ralph-orange: #58a6ff;
    --ralph-orange-dim: rgba(88, 166, 255, 0.15);
    --ralph-orange-glow: rgba(88, 166, 255, 0.4);
    
    /* Backgrounds */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-card: #161b22;
    --bg-elevated: #1c2128;
    --bg-hover: #21262d;
    
    /* Borders */
    --border: #30363d;
    --border-default: #30363d;
    --border-light: #484f58;
    
    /* Text */
    --text: #e6edf3;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --text-faint: #6e7681;
    
    /* Status Colors */
    --success: #3fb950;
    --success-dim: rgba(63, 185, 80, 0.15);
    --status-success: #3fb950;
    --warning: #d29922;
    --warning-dim: rgba(210, 153, 34, 0.15);
    --error: #f85149;
    --error-dim: rgba(248, 81, 73, 0.15);
    --status-error: #f85149;
    --accent-blue: #58a6ff;
    --accent-purple: #a371f7;
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-orange: 0 4px 16px var(--ralph-orange-glow);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* ===========================================
   RESET
   =========================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-blue);
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ===========================================
   TYPOGRAPHY
   =========================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.text-tiny { font-size: 0.75rem; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 600; }

/* ===========================================
   LAYOUT
   =========================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-lg);
}

@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }
}

/* ===========================================
   CARDS
   =========================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--ralph-orange);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ===========================================
   BUTTONS
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--ralph-orange);
    color: #000;
}

.btn-primary:hover {
    box-shadow: var(--shadow-orange);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--border-light);
    background: var(--bg-hover);
}

.btn-success {
    background: var(--success);
    color: #000;
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

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

.btn-lg {
    padding: var(--space-md) var(--space-lg);
    font-size: 1rem;
}

.btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
}

/* ===========================================
   INPUTS
   =========================================== */
.input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.input:focus {
    outline: none;
    border-color: var(--ralph-orange);
    box-shadow: 0 0 0 3px var(--ralph-orange-dim);
}

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

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===========================================
   BADGES
   =========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: var(--ralph-orange);
    color: #000;
}

.badge-success {
    background: var(--success-dim);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-dim);
    color: var(--warning);
}

.badge-error {
    background: var(--error-dim);
    color: var(--error);
}

/* ===========================================
   PROGRESS BARS
   =========================================== */
.progress {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--success));
    border-radius: 4px;
    transition: width var(--transition-normal);
}

/* ===========================================
   STATUS INDICATORS
   =========================================== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 2s infinite;
}

.status-dot.warning {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-dot.error {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.status-dot.inactive {
    background: var(--text-muted);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 8px rgba(63, 185, 80, 0);
    }
}

/* ===========================================
   TABLES
   =========================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

/* ===========================================
   LISTS
   =========================================== */
.list {
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: var(--bg-hover);
}

/* ===========================================
   MODALS
   =========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--ralph-orange);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

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

/* ===========================================
   SCROLLBARS
   =========================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-primary);
}

/* ===========================================
   UTILITIES
   =========================================== */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Grid */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Spacing */
.m-0 { margin: 0; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* Text */
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Colors */
.text-orange { color: var(--accent-blue); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-blue { color: var(--accent-blue); }

.bg-orange { background: var(--accent-blue); }
.bg-success { background: var(--success); }
.bg-warning { background: var(--warning); }
.bg-error { background: var(--error); }

/* ===========================================
   ANIMATIONS
   =========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

.animate-fade-in { animation: fadeIn 0.3s ease; }
.animate-fade-in-up { animation: fadeInUp 0.3s ease; }
.animate-slide-in { animation: slideIn 0.3s ease; }

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===========================================
   PAGINATION
   =========================================== */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
}

.pagination-numbers {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.pagination-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-btn.pagination-prev,
.pagination-btn.pagination-next {
    min-width: 80px;
}

.pagination-page {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-page:hover:not(.active):not(.ellipsis) {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text);
}

.pagination-page.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
    font-weight: 600;
}

.pagination-page.ellipsis {
    background: transparent;
    border: none;
    cursor: default;
    color: var(--text-muted);
    min-width: 30px;
}

/* Mobile pagination adjustments */
@media (max-width: 600px) {
    .pagination-container {
        flex-wrap: wrap;
        gap: var(--space-xs);
    }
    
    .pagination-btn.pagination-prev,
    .pagination-btn.pagination-next {
        min-width: 60px;
        padding: var(--space-sm);
        font-size: 13px;
    }
    
    .pagination-page {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    .pagination-numbers {
        order: 2;
        width: 100%;
        justify-content: center;
        margin-top: var(--space-sm);
    }
}

/* ===========================================
   RESPONSIVE - MOBILE FIRST
   =========================================== */

/* Mobile-specific improvements (375px iPhone target) */
@media (max-width: 480px) {
    html {
        font-size: 14px; /* Base font size minimum 14px */
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
        padding-top: 60px; /* Space for top mobile nav */
    }
    
    .container {
        padding: var(--space-sm);
        max-width: 100%;
        overflow-x: hidden;
    }
    
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.1rem; }
    
    /* Ensure minimum readable font sizes */
    p, span, div, li {
        font-size: max(14px, inherit);
    }
    
    .text-small {
        font-size: 14px; /* Override to ensure readability */
    }
    
    .text-tiny {
        font-size: 13px; /* Slightly smaller but still readable */
    }
    
    /* Stats bar - 2 columns on small mobile */
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        padding: var(--space-md);
        gap: var(--space-sm);
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .stat-label {
        font-size: 12px; /* Minimum for labels */
    }
    
    /* Section cards */
    .section-card {
        padding: var(--space-md);
        border-radius: var(--radius-md);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    /* Buttons - touch-friendly 44px minimum */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: var(--space-sm) var(--space-md);
        font-size: 14px;
    }
    
    .btn-sm {
        min-height: 40px;
        font-size: 14px;
    }
    
    .btn-lg {
        min-height: 48px;
        font-size: 16px;
    }
    
    /* Inputs - larger touch targets */
    .input, .select {
        min-height: 44px;
        padding: var(--space-sm) var(--space-md);
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
    
    /* Decision cards */
    .decision-card {
        padding: var(--space-md);
    }
    
    .decision-header {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .decision-options {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .decision-option-btn,
    .decision-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
        font-size: 14px;
    }
    
    /* Projects grid - single column */
    .projects-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    /* Modal improvements */
    .modal {
        margin: var(--space-sm);
        max-height: calc(100vh - 32px);
        padding: var(--space-md);
        width: calc(100% - 16px);
    }
    
    .modal-header {
        margin-bottom: var(--space-md);
    }
    
    .modal-actions {
        flex-direction: column;
        gap: var(--space-sm);
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    /* Card adjustments */
    .card {
        padding: var(--space-md);
        border-radius: var(--radius-md);
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-sm);
    }
    
    /* Table responsiveness */
    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table th,
    .table td {
        padding: var(--space-sm);
        font-size: 14px;
    }
    
    /* List items - touch friendly */
    .list-item {
        padding: var(--space-md);
        min-height: 44px;
    }
    
    /* Badge readability */
    .badge {
        font-size: 12px;
        padding: 0.2rem 0.6rem;
    }
    
    /* Toast positioning for mobile */
    .toast {
        bottom: 80px;
        left: var(--space-md);
        right: var(--space-md);
        transform: translateY(20px);
        max-width: calc(100% - 32px);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    
    /* Ensure all interactive elements have minimum touch target */
    button, 
    a:not(.logo), 
    input, 
    select, 
    textarea,
    .nav-link,
    .mobile-nav-item {
        min-height: 44px;
    }
    
    /* Fix horizontal overflow */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    .container {
        overflow-x: hidden;
        padding: var(--space-md);
    }
    
    /* Better spacing for cards */
    .card {
        padding: var(--space-md);
    }
    
    /* Filter buttons - wrap and touch-friendly */
    .activity-filters {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-sm);
    }
    
    .filter-btn {
        min-height: 44px;
        padding: var(--space-sm) var(--space-md);
        font-size: 14px;
    }
    
    /* Hide desktop header nav on tablet/mobile */
    .header .nav {
        display: none;
    }
    
    /* Ensure mobile nav is visible */
    .mobile-nav {
        display: flex !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* ===========================================
   PRINT
   =========================================== */
@media print {
    body {
        background: #fff;
        color: #000;
    }
    
    .card {
        border: 1px solid #ccc;
        background: #fff;
        page-break-inside: avoid;
    }
    
    .btn, .toast, .mobile-nav {
        display: none !important;
    }
}

/* ===========================================
   HEADER & NAVIGATION
   =========================================== */
.header {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-primary) 100%);
    border-bottom: 2px solid var(--accent-blue);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-emoji {
    font-size: 1.5rem;
}

.nav {
    display: flex;
    gap: 0.25rem;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: var(--ralph-orange-dim);
    color: var(--accent-blue);
}

/* ===========================================
   MOBILE NAVIGATION
   =========================================== */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent-blue);
    padding: 0.5rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top, 0px));
    justify-content: space-around;
    z-index: 100;
    backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
    }
    
    .header .nav {
        display: none;
    }
    
    /* Hide full header on mobile, mobile-nav replaces it */
    .header {
        display: none;
    }
    
    body {
        padding-top: calc(70px + env(safe-area-inset-top, 0px));
        padding-bottom: 0;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    min-height: 56px; /* Larger than 44px minimum for easier tapping */
    min-width: 60px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item.active {
    color: var(--accent-blue);
    background: var(--ralph-orange-dim);
    font-weight: 600;
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    color: var(--accent-blue);
    background: var(--ralph-orange-dim);
}

.mobile-nav-icon {
    font-size: 1.5rem;
}

/* Mobile nav label text */
.mobile-nav-item span:not(.mobile-nav-icon) {
    font-size: 12px;
    font-weight: 500;
}

/* ===========================================
   SECTION CARDS
   =========================================== */
.section-card {
    background: var(--bg-secondary, var(--bg-card));
    border: 1px solid var(--border-default, var(--border));
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

.section-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===========================================
   STATS BAR
   =========================================== */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

.stat-value.warning {
    color: var(--warning);
}

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

.stat-value.blue {
    color: var(--accent-blue);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===========================================
   DECISION CARDS (decisions.html)
   =========================================== */
.decisions-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.decision-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all var(--transition-normal);
    border-left: 4px solid var(--accent-blue);
}

.decision-card:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

.decision-card.pending {
    border-left-color: var(--accent-blue);
}

.decision-card.decided {
    border-left-color: var(--success);
    opacity: 0.8;
}

.decision-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
}

.decision-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.decision-context {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-md);
    line-height: 1.6;
}

.decision-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.decision-option-btn {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.decision-option-btn:hover {
    border-color: var(--accent-blue);
    background: var(--ralph-orange-dim);
    color: var(--accent-blue);
}

.decision-option-btn.yes {
    background: var(--success);
    border-color: var(--success);
    color: #000;
}

.decision-option-btn.yes:hover {
    background: #4cc764;
    box-shadow: 0 4px 12px rgba(63, 185, 80, 0.3);
}

.decision-option-btn.no {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.decision-option-btn.no:hover {
    background: #ff6b61;
    box-shadow: 0 4px 12px rgba(248, 81, 73, 0.3);
}

.decision-option-btn.wait {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-muted);
}

.decision-option-btn.wait:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* Decision history items */
.decision-history-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition-fast);
}

.decision-history-item:last-child {
    border-bottom: none;
}

.decision-history-item:hover {
    background: var(--bg-hover);
}

.decision-history-badge {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.decision-history-badge.yes {
    background: var(--success-dim);
    color: var(--success);
}

.decision-history-badge.no {
    background: var(--error-dim);
    color: var(--error);
}

.decision-history-badge.wait {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

/* ===========================================
   EMPTY STATES
   =========================================== */
.empty-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-sm);
}

.empty-state-description {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ===========================================
   SKELETON LOADING
   =========================================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-hover) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-sm);
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.shorter {
    width: 40%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===========================================
   PROJECT CARDS (for decisions by project)
   =========================================== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.project-card:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===========================================
   DECISION BUTTONS (for decisions.html)
   =========================================== */
.decision-btn {
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.decision-btn:hover {
    transform: translateY(-2px);
}

.decision-btn.yes {
    background: var(--success);
    color: #000;
}

.decision-btn.yes:hover {
    box-shadow: 0 4px 12px rgba(63, 185, 80, 0.4);
}

.decision-btn.no {
    background: var(--error);
    color: #fff;
}

.decision-btn.no:hover {
    box-shadow: 0 4px 12px rgba(248, 81, 73, 0.4);
}

.decision-btn.wait {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
}

.decision-btn.wait:hover {
    border-color: var(--accent-blue);
    background: var(--ralph-orange-dim);
    color: var(--accent-blue);
}

.decision-btn.gradual {
    background: var(--accent-blue);
    color: #000;
}

.decision-btn.gradual:hover {
    box-shadow: 0 4px 12px var(--ralph-orange-glow);
}

/* Decision choice badges */
.decision-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    min-width: 60px;
}

.decision-choice.yes {
    background: var(--success-dim);
    color: var(--success);
}

.decision-choice.no {
    background: var(--error-dim);
    color: var(--error);
}

.decision-choice.wait {
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.decision-choice.gradual {
    background: var(--ralph-orange-dim);
    color: var(--accent-blue);
}

/* Risk analysis styling */
.decision-risk {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
}

.risk-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--error);
    margin-bottom: var(--space-xs);
}

.risk-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* AI recommendation styling */
.decision-recommendation {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    background: var(--ralph-orange-dim);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin: var(--space-md) 0;
}

.recommendation-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.recommendation-content {
    flex: 1;
}

.recommendation-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-blue);
    margin-bottom: var(--space-xs);
}

.recommendation-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Decision project badge */
.decision-project {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0.2rem 0.6rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

/* Decision title */
.decision-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

/* ===========================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   =========================================== */

/* Reduce complexity of animations on mobile */
@media (max-width: 768px) {
    /* Simplify or disable hover effects on touch */
    .card:hover,
    .project-card:hover,
    .decision-card:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Reduce animation complexity */
    @keyframes pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.7; }
    }
    
    /* Simplify transitions */
    * {
        transition-duration: 0.15s !important;
    }
    
    /* Remove backdrop-filter on low-end devices (expensive) */
    @supports not (backdrop-filter: blur(10px)) {
        .mobile-nav,
        .header {
            background: var(--bg-card);
        }
    }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================================
   ADDITIONAL MOBILE LAYOUT FIXES (375px)
   =========================================== */
@media (max-width: 375px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 0.5rem;
    }
    
    /* Extra small screen stat adjustments */
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    /* Tighter card padding */
    .card,
    .section-card,
    .decision-card {
        padding: 0.75rem;
    }
    
    /* Stack mobile nav items closer */
    .mobile-nav {
        padding: 0.35rem 0.25rem;
    }
    
    .mobile-nav-item {
        padding: 0.4rem 0.5rem;
        min-width: 50px;
    }
    
    .mobile-nav-icon {
        font-size: 1.25rem;
    }
    
    /* Full-width buttons on tiny screens */
    .btn {
        width: 100%;
    }
    
    /* Decision buttons stacked */
    .decision-options,
    .decision-buttons {
        flex-direction: column;
    }
    
    .decision-option-btn,
    .decision-btn {
        width: 100%;
    }
}

/* ===========================================
   TOUCH INTERACTION IMPROVEMENTS
   =========================================== */
@media (hover: none) and (pointer: coarse) {
    /* Touch devices: larger hit areas */
    .btn,
    .nav-link,
    .mobile-nav-item,
    .filter-btn,
    .decision-btn,
    .decision-option-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover states on touch */
    .btn:hover {
        transform: none;
    }
    
    /* Active states for touch feedback */
    .btn:active,
    .mobile-nav-item:active,
    .decision-btn:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* ===========================================
   LOADING STATE SKELETON OPTIMIZATION
   =========================================== */
.skeleton {
    background: var(--bg-elevated);
    animation: shimmer 1.5s infinite;
}

@media (max-width: 768px) {
    /* Simpler skeleton animation on mobile */
    .skeleton {
        animation: none;
        opacity: 0.5;
    }
}
