/* Usage Page Styles */

.usage-page {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.usage-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.tier-info {
    font-size: 15px;
    color: var(--text-secondary);
}

.tier-info span {
    color: var(--accent);
    font-weight: 600;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
}

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

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 20px;
    color: var(--text-secondary);
}

.loading-state .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-state p {
    font-size: 15px;
}

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

.error-state {
    text-align: center;
    padding: 60px 20px;
}

.error-state p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Stats Summary - Full Width Table Layout */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

/* Generations Grid */
.generations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: auto;
    max-height: 800px;
}

.generation-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s;
}

.generation-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
}

.generation-card.has-error {
    cursor: default;
}

.generation-card.has-error:hover {
    border-color: var(--border);
}

.generation-image {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

.generation-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-error-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 13px;
}

.image-error-placeholder svg {
    opacity: 0.5;
}

.generation-info {
    padding: 16px;
}

.generation-prompt {
    font-size: 14px;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.generation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.empty-state a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* Detailed Stats */
.detailed-stats {
    margin-top: 40px;
}

.detailed-stats h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 20px 0;
}

.stats-table {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.stats-table h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.stats-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.stats-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table td:first-child {
    font-weight: 500;
    color: var(--text-primary);
}

.stats-table td:nth-child:last-child {
    color: var(--accent);
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #2563eb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .usage-page {
        padding: 20px 16px calc(100px + env(safe-area-inset-bottom, 0px));
        max-width: 100vw;
        overflow-x: hidden;
    }

    .usage-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .usage-header h1 {
        font-size: 24px;
    }

    .tabs {
        gap: 4px;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 14px;
        white-space: nowrap;
    }

    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 1px;
    }

    .stat-card {
        padding: 16px 12px;
        gap: 8px;
    }

    .stat-value {
        font-size: 24px;
    }

    .generations-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Make stats table cards instead of table on mobile */
    .stats-table {
        padding: 16px;
        overflow-x: hidden;
    }

    .stats-table table,
    .stats-table thead,
    .stats-table tbody,
    .stats-table th,
    .stats-table td,
    .stats-table tr {
        display: block;
    }

    .stats-table thead {
        display: none;
    }

    .stats-table tr {
        margin-bottom: 16px;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 12px;
        background: var(--bg-primary);
    }

    .stats-table td {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
        font-size: 14px;
    }

    .stats-table td:last-child {
        border-bottom: none;
    }

    .stats-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
    }

    .stats-table td:first-child {
        font-weight: 600;
        color: var(--text-primary);
        background: var(--bg-secondary);
        margin: -12px -12px 8px;
        padding: 12px;
        border-radius: 8px 8px 0 0;
    }

    .stats-table td:first-child::before {
        display: none;
    }
}

@media (max-width: 480px) {
    .usage-page {
        padding: 16px 12px calc(100px + env(safe-area-inset-bottom, 0px));
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 20px;
    }

    .generations-grid {
        grid-template-columns: 1fr;
    }

    .generation-image {
        aspect-ratio: 16 / 9;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .stats-table h3 {
        font-size: 12px;
    }
}
