/*
 * Document Intelligence - Main Layout
 * Page structure and layout styles
 */

/* ========== Layout ========== */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== Header ========== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--backdrop-blur);
}

.header-inner {
    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.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    color: white;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
}

.header-stat-value {
    font-weight: 600;
    color: var(--accent-light);
}

.queue-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem;
    background: var(--warning-bg);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--warning);
    font-weight: 500;
}

.queue-indicator.active {
    display: flex;
}

/* ========== Main Content ========== */
.main {
    flex: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    width: 100%;
}

/* ========== Sections ========== */
.section {
    margin-bottom: 2.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

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

/* ========== Filter Tabs ========== */
.filter-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.filter-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.filter-tab.active {
    background: var(--accent);
    color: white;
}

/* ========== Documents Grid ========== */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

/* ========== Document Card ========== */
.doc-card {
    animation: slideUp 0.3s ease forwards;
    animation-delay: calc(var(--index, 0) * 50ms);
}

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

.doc-card .card-title {
    word-break: break-word;
    line-height: 1.3;
}

.doc-progress {
    margin: 1rem 0;
}

.doc-progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* ========== Empty State ========== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-muted);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    color: var(--text-secondary);
}

/* ========== Upload Queue ========== */
.upload-queue {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-queue:empty {
    display: none;
}

.queue-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
}

.queue-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.queue-item-name {
    font-weight: 500;
    font-size: 0.875rem;
    word-break: break-word;
}

.queue-item-progress {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* ========== Images Grid ========== */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.image-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.image-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.image-thumbnail {
    width: 100%;
    height: 140px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-info {
    padding: 0.75rem;
}

.image-name {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.image-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ========== Pages Grid ========== */
.pages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.pages-header span {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.page-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}

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

.page-thumbnail {
    width: 100%;
    height: 280px;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.page-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.page-info {
    padding: 0.75rem;
    text-align: center;
}

.page-number {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* ========== HTML Preview ========== */
.html-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: white;
}

.html-preview iframe {
    width: 100%;
    height: 550px;
    border: none;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .header-inner {
        flex-wrap: wrap;
    }

    .logo-subtitle {
        display: none;
    }

    .main {
        padding: 1.25rem 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .filter-tabs {
        width: 100%;
        overflow-x: auto;
    }
}
