/**
 * PDF Text Extractor - Stylesheet
 * 
 * Clean, minimal design for the PDF text extraction tool.
 * 
 * Author: Yivani
 * Website: https://yivani.dev
 * Contact: contact@yivani.dev
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    /* Colors */
    --bg: #fafafa;
    --bg-elevated: #ffffff;
    --bg-subtle: #f3f4f6;
    --bg-hover: #e5e7eb;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #dbeafe;
    --success: #10b981;
    --success-light: #d1fae5;
    --error: #ef4444;
    --error-light: #fee2e2;
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    
    /* Layout */
    --radius: 6px;
    --radius-lg: 10px;
    --header-height: 56px;
    --footer-height: 48px;
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

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

body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.5; 
    min-height: 100vh;
}

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

/* ============================================
   HEADER
   ============================================ */
.header { 
    position: sticky; 
    top: 0; 
    z-index: 100; 
    background: var(--bg-elevated); 
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
}

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

.logo { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    font-weight: 600; 
    font-size: 1rem; 
}

.nav-btn { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    padding: 0.5rem 0.875rem; 
    font-size: 0.875rem; 
    font-weight: 500; 
    color: var(--text-secondary); 
    background: transparent; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    cursor: pointer; 
    transition: all 0.15s ease;
}

.nav-btn:hover { 
    background: var(--bg-subtle); 
    border-color: var(--border-strong); 
    color: var(--text); 
}

/* ============================================
   BUTTONS
   ============================================ */
.btn { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.5rem; 
    padding: 0.625rem 1rem; 
    font-family: inherit; 
    font-size: 0.875rem; 
    font-weight: 500; 
    border: none; 
    border-radius: var(--radius); 
    cursor: pointer; 
    transition: all 0.15s ease;
}

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

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

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

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

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

.btn-outline:hover { 
    background: var(--bg-subtle); 
    border-color: var(--border-strong); 
    color: var(--text); 
}

.btn-full { 
    width: 100%; 
}

.btn.danger { 
    color: var(--error); 
}

.btn.danger:hover { 
    background: var(--error-light); 
}

/* Icon button (small, square) */
.icon-btn { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 28px; 
    height: 28px; 
    color: var(--text-muted); 
    background: transparent; 
    border: none; 
    border-radius: var(--radius); 
    cursor: pointer; 
}

.icon-btn:hover { 
    background: var(--bg-subtle); 
    color: var(--text); 
}

/* Text button (for toolbars) */
.text-btn { 
    padding: 0.375rem 0.75rem; 
    font-size: 0.8125rem; 
    font-weight: 500; 
    color: var(--text-secondary); 
    background: var(--bg-subtle); 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    cursor: pointer; 
    white-space: nowrap;
}

.text-btn:hover { 
    background: var(--border); 
    color: var(--text); 
}

.text-btn.danger { 
    color: var(--error); 
}

.text-btn.danger:hover { 
    background: var(--error-light); 
}

/* Toolbar button */
.tool-btn { 
    display: flex; 
    align-items: center; 
    gap: 0.375rem; 
    padding: 0.5rem 0.75rem; 
    font-size: 0.8125rem; 
    font-weight: 500; 
    color: var(--text-secondary); 
    background: transparent; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    cursor: pointer; 
}

.tool-btn:hover { 
    background: var(--bg-subtle); 
    color: var(--text); 
}

/* Floating action button */
.fab { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 40px; 
    height: 40px; 
    color: var(--text-secondary); 
    background: var(--bg-elevated); 
    border: 1px solid var(--border); 
    border-radius: 50%; 
    cursor: pointer; 
    box-shadow: var(--shadow-md); 
    transition: all 0.2s ease;
    opacity: 1;
    pointer-events: auto;
}

.fab:hover:not(:disabled) { 
    background: var(--accent); 
    color: white; 
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px -2px rgb(0 0 0 / 0.15);
}

.fab:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow);
}

.fab:disabled,
.fab[disabled] {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   UPLOAD VIEW
   ============================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.view {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-container { 
    max-width: 640px; 
    margin: 0 auto; 
    padding: 2.5rem 1.5rem; 
}

.upload-header { 
    text-align: center; 
    margin-bottom: 1.5rem; 
}

.upload-header h1 { 
    font-size: 1.5rem; 
    font-weight: 600; 
    margin-bottom: 0.375rem; 
}

.upload-header p { 
    color: var(--text-muted); 
    font-size: 0.9375rem; 
}

.upload-card { 
    background: var(--bg-elevated); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-lg); 
    overflow: hidden;
}

/* Dropzone area */
.dropzone { 
    padding: 2.5rem 2rem; 
    text-align: center; 
    cursor: pointer; 
    transition: all 0.2s ease; 
}

.dropzone:hover { 
    background: var(--bg-subtle); 
}

.dropzone.dragover { 
    background: var(--accent-light); 
    border: 2px dashed var(--accent); 
    margin: -1px; 
}

.dropzone-inner { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 0.5rem; 
}

.dropzone-icon { 
    color: var(--text-muted); 
    margin-bottom: 0.25rem; 
}

.dropzone-title { 
    font-size: 1rem; 
    font-weight: 500; 
}

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

.dropzone-subtitle span { 
    color: var(--accent); 
    font-weight: 500; 
}

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

/* File list section */
.file-section { 
    border-top: 1px solid var(--border); 
    max-height: 300px; 
    display: flex; 
    flex-direction: column; 
}

.file-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0.625rem 1rem; 
    background: var(--bg-subtle); 
    border-bottom: 1px solid var(--border);
}

.file-count { 
    font-size: 0.8125rem; 
    font-weight: 500; 
    color: var(--text-secondary); 
}

.file-clear { 
    font-size: 0.8125rem; 
    color: var(--text-muted); 
    background: none; 
    border: none; 
    cursor: pointer; 
    padding: 0.25rem 0.5rem; 
    border-radius: var(--radius);
}

.file-clear:hover { 
    color: var(--error); 
    background: var(--error-light); 
}

.file-list { 
    overflow-y: auto; 
    padding: 0.5rem; 
    max-height: 220px; 
}

/* Individual file item */
.file-item { 
    display: flex; 
    align-items: center; 
    gap: 0.625rem; 
    padding: 0.5rem 0.625rem; 
    border-radius: var(--radius); 
    transition: all 0.15s ease;
}

.file-item:hover { 
    background: var(--bg-subtle); 
}

.file-icon { 
    color: #dc2626; 
    flex-shrink: 0; 
}

.file-info { 
    flex: 1; 
    min-width: 0; 
}

.file-name { 
    font-size: 0.875rem; 
    font-weight: 500; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

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

.file-remove { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    width: 26px; 
    height: 26px; 
    color: var(--text-muted); 
    background: none; 
    border: none; 
    border-radius: var(--radius); 
    cursor: pointer; 
    flex-shrink: 0;
}

.file-remove:hover { 
    color: var(--error); 
    background: var(--error-light); 
}

/* Sticky action bar */
.action-bar { 
    display: flex; 
    gap: 0.625rem; 
    justify-content: flex-end; 
    padding: 0.875rem 1rem; 
    background: var(--bg-elevated); 
    border-top: 1px solid var(--border); 
    position: sticky; 
    bottom: 0;
}

/* ============================================
   PROCESSING VIEW
   ============================================ */
.processing-container { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 2rem; 
}

.processing-content { 
    text-align: center; 
    max-width: 320px; 
}

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

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

.processing-content h2 { 
    font-size: 1.125rem; 
    font-weight: 600; 
    margin-bottom: 0.375rem; 
}

.processing-content p { 
    color: var(--text-muted); 
    font-size: 0.875rem; 
    margin-bottom: 1rem; 
}

.progress-bar { 
    height: 4px; 
    background: var(--border); 
    border-radius: 2px; 
    overflow: hidden; 
}

.progress-fill { 
    height: 100%; 
    background: var(--accent); 
    width: 0%; 
    transition: width 0.3s ease; 
}

/* ============================================
   RESULTS VIEW
   ============================================ */
.results-layout { 
    flex: 1; 
    display: flex; 
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* Left side: Editor section */
.editor-section { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-width: 0; 
}

/* Search toolbar */
.search-toolbar { 
    background: var(--bg-elevated); 
    border-bottom: 1px solid var(--border); 
    padding: 0.75rem 1rem;
}

.search-row, .replace-row, .transform-row { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    margin-bottom: 0.5rem;
}

.replace-row { 
    margin-bottom: 0.5rem; 
}

.transform-row { 
    margin-bottom: 0; 
    gap: 0.375rem; 
    flex-wrap: wrap; 
    align-items: center;
}

.divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

/* Search input styling */
.search-input-wrapper { 
    flex: 1; 
    position: relative; 
    display: flex; 
    align-items: center;
}

.search-icon { 
    position: absolute; 
    left: 0.625rem; 
    color: var(--text-muted); 
}

.search-input-wrapper input { 
    width: 100%; 
    padding: 0.5rem 0.625rem 0.5rem 2rem; 
    font-family: inherit; 
    font-size: 0.875rem; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    outline: none;
}

.search-input-wrapper input:focus { 
    border-color: var(--accent); 
}

#replaceInput { 
    padding-left: 0.625rem; 
}

.match-count { 
    position: absolute; 
    right: 0.5rem; 
    font-size: 0.6875rem; 
    font-weight: 500;
    color: var(--text-muted); 
    background: var(--bg-subtle);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    pointer-events: none;
}

.search-actions, .replace-actions { 
    display: flex; 
    align-items: center; 
    gap: 0.25rem; 
}

/* Editor toolbar */
.editor-toolbar { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0.625rem 1rem; 
    background: var(--bg-elevated); 
    border-bottom: 1px solid var(--border);
}

.toolbar-left { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
}

.toolbar-left h2 { 
    font-size: 0.9375rem; 
    font-weight: 600; 
}

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

.toolbar-right { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
}

/* Text editor container */
.editor-container { 
    flex: 1; 
    position: relative; 
    overflow: hidden;
}

#resultText { 
    width: 100%; 
    height: 100%; 
    padding: 1rem 1.5rem; 
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace; 
    font-size: 0.8125rem; 
    line-height: 1.6; 
    color: var(--text); 
    background: var(--bg); 
    border: none; 
    resize: none; 
    outline: none;
    white-space: pre;
    tab-size: 4;
    -moz-tab-size: 4;
}

#resultText::placeholder { 
    color: var(--text-muted); 
}

#resultText::selection {
    background: #fde047;
    color: var(--text);
}

/* Floating scroll buttons */
.floating-buttons { 
    position: absolute; 
    right: 1.5rem; 
    bottom: 1.5rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.625rem;
    z-index: 10;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    border-radius: 50px;
}

/* ============================================
   RIGHT SIDEBAR (Summary Panel)
   ============================================ */
.summary-panel { 
    width: 280px; 
    background: var(--bg-elevated); 
    border-left: 1px solid var(--border); 
    padding: 1rem; 
    display: flex; 
    flex-direction: column; 
    gap: 1rem; 
    overflow-y: auto;
}

.panel-card { 
    background: var(--bg); 
    border: 1px solid var(--border); 
    border-radius: var(--radius-lg); 
    overflow: hidden;
}

.panel-card > h3, .panel-header { 
    padding: 0.875rem 1rem; 
    font-size: 0.8125rem; 
    font-weight: 600; 
    color: var(--text-secondary); 
    text-transform: uppercase; 
    letter-spacing: 0.025em; 
    border-bottom: 1px solid var(--border);
}

.panel-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0.75rem 1rem;
}

.panel-header h3 { 
    font-size: 0.8125rem; 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 0.025em; 
}

.badge { 
    padding: 0.125rem 0.5rem; 
    font-size: 0.6875rem; 
    font-weight: 600; 
    background: var(--accent-light); 
    color: var(--accent); 
    border-radius: 999px;
}

/* Statistics list */
.stats-list { 
    padding: 0.75rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.625rem; 
}

.stat-item { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    padding: 0.625rem; 
    background: var(--bg-elevated); 
    border-radius: var(--radius);
}

.stat-icon { 
    color: var(--text-muted); 
}

.stat-content { 
    display: flex; 
    flex-direction: column; 
}

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

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

/* Files list in sidebar */
.files-scroll { 
    max-height: 300px; 
    overflow-y: auto; 
    padding: 0.5rem;
}

.file-result { 
    padding: 0.625rem 0.75rem; 
    border-radius: var(--radius); 
    font-size: 0.8125rem; 
    margin-bottom: 0.375rem;
}

.file-result:last-child { 
    margin-bottom: 0; 
}

.file-result.success { 
    background: var(--success-light); 
    border-left: 3px solid var(--success);
}

.file-result.error { 
    background: var(--error-light); 
    border-left: 3px solid var(--error);
}

.file-result-name { 
    font-weight: 500; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-bottom: 0.125rem; 
}

.file-result-meta { 
    font-size: 0.75rem; 
    color: var(--text-muted); 
}

.file-result.error .file-result-meta { 
    color: var(--error); 
}

/* Actions in sidebar */
.actions-card { 
    padding: 0.875rem; 
}

.actions-card .btn { 
    justify-content: center; 
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 0.875rem 1.5rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.footer-link:hover {
    color: var(--accent);
    background: var(--bg-subtle);
}

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

.footer a:hover {
    color: var(--accent);
}

@media (max-width: 640px) {
    .footer-content {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .footer-left,
    .footer-right {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container { 
    position: fixed; 
    bottom: 1rem; 
    right: 1rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
    z-index: 1000;
}

.toast { 
    display: flex; 
    align-items: center; 
    gap: 0.5rem; 
    padding: 0.75rem 1rem; 
    background: var(--bg-elevated); 
    border: 1px solid var(--border); 
    border-left: 3px solid var(--success); 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-md); 
    font-size: 0.875rem; 
    animation: slideIn 0.2s ease;
}

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

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

/* ============================================
   SCROLLBAR STYLES
   ============================================ */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}

::-webkit-scrollbar-track { 
    background: transparent; 
}

::-webkit-scrollbar-thumb { 
    background: var(--border-strong); 
    border-radius: 3px; 
}

::-webkit-scrollbar-thumb:hover { 
    background: #a3a3a3; 
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
    .results-layout { 
        flex-direction: column; 
    }
    
    .summary-panel { 
        width: 100%; 
        border-left: none; 
        border-top: 1px solid var(--border);
        flex-direction: row; 
        flex-wrap: wrap;
    }
    
    .panel-card { 
        flex: 1; 
        min-width: 250px; 
    }
    
    .files-scroll { 
        max-height: 200px; 
    }
    
    .floating-buttons { 
        right: 0.75rem; 
        bottom: 0.75rem; 
    }
}

@media (max-width: 640px) {
    .header-content { 
        padding: 0 1rem; 
    }
    
    .upload-container { 
        padding: 1.5rem 1rem; 
    }
    
    .dropzone { 
        padding: 2rem 1.5rem; 
    }
    
    .stats-grid {
        gap: 0.5rem;
    }
    
    .action-bar { 
        flex-direction: column; 
    }
    
    .btn { 
        width: 100%; 
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}
