:root {
    --primary-color: #007AFF;
    --bg-color: #F5F5F7;
    --card-bg: #FFFFFF;
    --text-primary: #1D1D1F;
    --text-secondary: #86868B;
    --border-radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    margin: 0;
    padding: 20px;
    line-height: 1.5;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* Top Navigation */
.top-nav {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 90; /* Below auth overlay (1000) */
}

.nav-content {
    max-width: 1000px; /* Slightly wider than container */
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    height: 40px;
}

/* Header */
.app-header {
    margin-top: 40px;
    margin-bottom: 40px;
    text-align: center;
}

.header-content {
    display: block;
}

.title-container {
    text-align: center;
}

.app-header h1 {
    font-size: 2.8rem;
    margin: 0 0 12px 0;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #1D1D1F 0%, #434344 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 400;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
}

.quota-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #F2F2F7;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.quota-container:hover {
    background: #E5E5EA;
}

.quota-text {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.quota-tip {
    cursor: help;
    font-size: 0.9rem;
    opacity: 0.5;
    display: flex;
    align-items: center;
}

.user-email {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .app-header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .user-email {
        max-width: 120px;
        display: none; /* Hide email on mobile to save space */
    }
    
    .nav-content {
        justify-content: center; /* Center profile on mobile */
    }
}

.logout-btn {
    background: none;
    border: 1px solid #E5E5EA;
    padding: 6px 12px;
    border-radius: 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #F5F5F7;
    border-color: #D2D2D7;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

/* Search Section */
.search-section {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 150px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #D2D2D7;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

/* Buttons */
.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

.primary-btn:hover {
    background-color: #0066CC;
}

.outline-btn {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

.ai-btn {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
    transition: transform 0.2s;
}

.ai-btn:hover {
    transform: scale(1.05);
}

/* App Info */
.app-info-content {
    display: flex;
    align-items: center;
    gap: 20px;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.app-icon {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    border: 1px solid #eee;
}

.app-details h2 {
    margin: 0 0 8px 0;
}

.app-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Reviews Grid */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.review-card {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.review-header {
    margin-bottom: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    flex-shrink: 0;
}

.review-meta-top {
    display: flex;
    flex-direction: column;
}

.author-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.stars {
    color: #FF9500;
    font-size: 0.9rem;
}

.review-title {
    font-weight: bold;
    margin: 12px 0 8px 0;
    font-size: 1rem;
}

.review-body {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 12px;
}

.review-meta-bottom {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Analysis Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.analysis-content {
    line-height: 1.8;
}

.analysis-content h3 {
    color: var(--primary-color);
    margin-top: 24px;
}

.analysis-content ul {
    padding-left: 20px;
}

.analysis-content li {
    margin-bottom: 8px;
}

/* Loading */
.loading-state {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.app-footer {
    text-align: center;
    margin-top: 60px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Auth Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.auth-box h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 2rem;
}

.auth-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    border-bottom: 1px solid #e5e5ea;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-tab:hover:not(.active) {
    color: var(--text-primary);
    background-color: #f5f5f7;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: white !important;
    color: #3c4043 !important;
    border: 1px solid #dadce0 !important;
    font-weight: 500;
}

.google-btn:hover {
    background: #f8f9fa !important;
    box-shadow: 0 1px 3px rgba(60,64,67,0.3);
}

.google-icon {
    width: 18px;
    height: 18px;
}

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #666;
    font-size: 14px;
    margin: 10px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e0e0e0;
}

.auth-divider span {
    padding: 0 10px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover {
    background: var(--primary-hover);
}

.auth-tip {
    margin-top: 12px;
    font-size: 12px;
    color: #666;
}

.full-width {
    width: 100%;
}

.auth-msg {
    margin-top: 16px;
    font-size: 0.9rem;
    min-height: 20px;
}

.auth-msg.success { color: #34C759; }
.auth-msg.error { color: #FF3B30; }
