/* Common styles for all pages - Airbnb Dashboard */

:root {
    --primary-color: #FF5A5F;
    --secondary-color: #00A699;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --error-color: #e53e3e;
    --background: #f7fafc;
    --surface: white;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --header-height: 120px;
    --nav-height: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Standardized Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

/* Navigation */
.nav-links {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Authentication Section */
.auth-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-success {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.status-error {
    background: rgba(229, 62, 62, 0.1);
    color: var(--error-color);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: #e5474c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 90, 95, 0.3);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background: #2d3748;
}

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

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Title */
.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

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

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

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

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

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    z-index: 1000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.notification.show {
    transform: translateX(0);
}

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

.notification.error {
    background: var(--error-color);
    color: white;
}

.notification.info {
    background: var(--secondary-color);
    color: white;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mobile Navigation */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

.nav-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

/* Responsive Tables */
.responsive-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

.responsive-table table {
    width: 100%;
    border-collapse: collapse;
}

.responsive-table th,
.responsive-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.responsive-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(72, 187, 120, 0.1);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(229, 62, 62, 0.1);
    color: var(--error-color);
}

/* Period selector */
.period-selector {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
    font-family: inherit;
}

@media (max-width: 768px) {
    .responsive-table {
        margin: 0 -1rem;
        padding: 0;
    }
    
    .responsive-table table {
        min-width: 500px;
    }
}

/* Mobile Cards */
@media (max-width: 768px) {
    :root {
        --header-height: auto;
    }
    
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 1rem;
    }
    
    /* Mobile Header */
    .header {
        position: relative;
    }
    
    .header-content {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
        margin-bottom: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Mobile Navigation */
    .nav-links {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100%;
        background: var(--surface);
        flex-direction: column;
        padding: 2rem 1rem;
        gap: 0;
        z-index: 200;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .nav-links.mobile-open {
        left: 0;
    }
    
    .nav-backdrop.show {
        display: block;
    }
    
    .nav-link {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        border-radius: 0;
        width: 100%;
        display: block;
    }
    
    .nav-link:last-child {
        border-bottom: none;
    }
    
    /* Mobile Auth Section */
    .auth-section {
        width: 100%;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .status {
        width: 100%;
        justify-content: center;
        padding: 0.75rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
    }
    
    /* Mobile Page Title */
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-subtitle {
        font-size: 1rem;
    }
    
    /* Mobile Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    /* Mobile Cards */
    .card {
        padding: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .card-title {
        font-size: 1.125rem;
    }
    
    /* Mobile Charts */
    .chart-container {
        margin-bottom: 1.5rem;
    }
    
    canvas {
        max-height: 300px !important;
    }
    
    /* Mobile Tables */
    table {
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    /* Mobile Notification */
    .notification {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 1rem;
        transform: translateY(100px);
    }
    
    .notification.show {
        transform: translateY(0);
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem;
    }
    
    .card {
        padding: 1rem;
    }
}

/* Touch-friendly elements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Hide button text on small screens */
@media (max-width: 480px) {
    .btn-text {
        display: none;
    }
    
    .btn {
        min-width: auto;
        padding: 0.625rem;
    }
    
    #sync-btn {
        margin-left: 0.5rem !important;
    }
}

/* Swipeable charts on mobile */
.chart-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}

.chart-scroll-item {
    scroll-snap-align: start;
    min-width: 100%;
}

/* Mobile-optimized grids */
@media (max-width: 768px) {
    .chart-grid {
        display: block;
    }
    
    .chart-grid > * {
        margin-bottom: 1.5rem;
    }
    
    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .metric-card {
        padding: 1rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
}

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(0px, env(safe-area-inset-top));
    }
    
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}