/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--surface);
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

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

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 500px;
    margin: 0 auto;
}

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

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    background: var(--surface);
    transition: var(--transition);
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: #f5f3ff;
}

.upload-icon {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-area h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

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

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

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

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--surface);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.tab {
    flex: 1;
    min-width: max-content;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

.tab.active {
    color: var(--primary-color);
    background: #eef2ff;
}

/* Tab Panels */
.tab-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.tab-panel {
    display: none;
}

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

.tab-panel h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.placeholder {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

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

.stat-card {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    text-align: center;
    color: white;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

/* Overview Details */
.overview-details {
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Text Content */
.text-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.page-selector label {
    font-weight: 500;
    color: var(--text-secondary);
}

.page-selector select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.page-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.text-content {
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    padding: 1rem;
    max-height: 500px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.page-text {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border-color);
}

.page-text:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.page-text h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Images Grid */
.images-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

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

.image-card {
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.image-card img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: white;
}

.image-card-info {
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Metadata Table */
.metadata-table {
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.metadata-row {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.metadata-row:last-child {
    border-bottom: none;
}

.metadata-key {
    flex: 0 0 40%;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(99, 102, 241, 0.05);
}

.metadata-value {
    flex: 1;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    word-break: break-all;
}

/* Accessibility */
.accessibility-score {
    text-align: center;
    margin-bottom: 2rem;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    box-shadow: var(--shadow-lg);
}

.score-circle.medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.score-circle.low {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.score-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

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

.accessibility-checks {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.check-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-color);
}

.check-item.warning {
    border-left-color: var(--warning-color);
}

.check-item.error {
    border-left-color: var(--error-color);
}

.check-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.check-content {
    flex: 1;
}

.check-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

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

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface-hover);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

#modalImage {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-sm);
}

.modal-info {
    padding: 0.75rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Footer */
.footer {
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

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

    .header h1 {
        font-size: 1.5rem;
    }

    .logo {
        width: 40px;
        height: 40px;
    }

    .main-content {
        padding: 1rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .tabs {
        padding: 0.125rem;
    }

    .tab {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .tab-content {
        padding: 1rem;
    }

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

    .stat-value {
        font-size: 1.5rem;
    }

    .metadata-row {
        flex-direction: column;
    }

    .metadata-key {
        flex: none;
    }

    .text-controls {
        justify-content: stretch;
    }

    .text-controls .btn {
        flex: 1;
    }

    .images-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .score-circle {
        width: 100px;
        height: 100px;
    }

    .score-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .file-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .page-selector {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Print Styles */
@media print {
    .upload-section,
    .tabs,
    .text-controls,
    .modal {
        display: none !important;
    }

    .tab-panel {
        display: block !important;
        page-break-inside: avoid;
    }
}
