/* TextFileCombiner Shared UI Components
   Agent 3: UI/UX & Performance Specialist
   Shared design system for OCR Tool and PDF Editor */

:root {
    /* Brand Colors */
    --primary-color: #667eea;
    --primary-hover: #5a67d8;
    --primary-light: #e9efff;
    --secondary-color: #48bb78;
    --secondary-hover: #38a169;
    --danger-color: #f56565;
    --danger-hover: #e53e3e;
    --warning-color: #ed8936;
    --warning-hover: #dd6b20;
    --info-color: #4299e1;
    --info-hover: #3182ce;
    
    /* Neutral Colors */
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-disabled: #a0aec0;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --shadow-color: rgba(0, 0, 0, 0.1);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
    
    /* Z-index Scale */
    --z-dropdown: 100;
    --z-modal: 200;
    --z-tooltip: 300;
    --z-notification: 400;
}

/* Performance Optimizations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navbar Styles */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #fafaf9;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 1000;
    height: 60px;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #667eea;
    font-size: 1.25rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.navbar-brand:hover {
    transform: translateY(-1px);
}

.navbar-brand svg {
    width: 40px;
    height: 40px;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 30px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    position: relative;
}

.nav-link {
    color: #667eea;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
}

.nav-link:hover {
    color: white;
    background: #667eea;
}

.nav-link.active {
    color: white;
    background: #667eea;
}

/* Dropdown styles */
.dropdown,
.nav-dropdown {
    position: relative;
}

.dropdown-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    margin-left: 4px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fafaf9;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 8px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    z-index: 1001;
}

.dropdown:hover .dropdown-menu,
.nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    color: #667eea;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #667eea;
    color: white;
}

.dropdown-item.active {
    background: #e9efff;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* Legal links section */
.navbar-legal {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.navbar-legal a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.navbar-legal a:hover {
    color: #6b7280;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: #667eea;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
}

/* Mobile menu */
.mobile-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: #fafaf9;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
    z-index: 9999;
}

.mobile-menu.open {
    display: block;
}

.mobile-nav {
    padding: 20px;
}

.mobile-nav-item {
    margin-bottom: 10px;
}

.mobile-nav-link {
    display: block;
    color: #667eea;
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.mobile-nav-link:hover {
    background: #667eea;
    color: white;
}

.mobile-nav-link.active {
    background: #e9efff;
}

/* Mobile dropdown styles */
.mobile-dropdown {
    margin-top: 8px;
    margin-left: 0;
}

.mobile-dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    color: #667eea;
    text-align: left;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.mobile-dropdown-toggle::after {
    content: '▼';
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.mobile-dropdown-toggle:hover {
    background: rgba(102, 126, 234, 0.1);
}

.mobile-dropdown-toggle.open::after {
    transform: rotate(180deg);
}

.mobile-dropdown-menu {
    display: none;
    margin-top: 8px;
    margin-left: 20px;
}

.mobile-dropdown-menu.open {
    display: block;
}

.mobile-legal {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(102, 126, 234, 0.1);
}

/* Adjust body padding for fixed navbar */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #fafaf9;
    min-height: 100vh;
    padding-top: 80px;
}

/* Responsive navbar styles */
@media (max-width: 1024px) {
    .navbar-nav {
        gap: 20px;
    }
    
    .nav-link {
        font-size: 0.9rem;
        padding: 6px 10px;
    }
}

@media (max-width: 768px) {
    .navbar-nav,
    .navbar-legal {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .navbar-brand svg {
        width: 32px;
        height: 32px;
    }
}

/* Lazy Loading Styles */
.lazy-load {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

.lazy-load.loaded {
    opacity: 1;
}

/* Tool Container Layout */
.tool-container {
    display: grid;
    grid-template-columns: 300px 1fr 300px;
    gap: 0;
    min-height: calc(100vh - 100px);
    position: relative;
}

@media (max-width: 1024px) {
    .tool-container {
        grid-template-columns: 1fr;
    }
    
    .tool-sidebar {
        display: none;
    }
}

/* Tool Main Area */
.tool-main {
    background: var(--bg-primary);
    padding: var(--spacing-xl);
    min-height: 600px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Drag & Drop Zone */
.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-2xl);
    text-align: center;
    transition: all var(--transition-normal);
    cursor: pointer;
    background: var(--bg-secondary);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.drop-zone.dragging {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(0.98);
}

.drop-zone-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-md);
    opacity: 0.5;
}

.drop-zone-text {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.drop-zone-hint {
    font-size: 0.875rem;
    color: var(--text-disabled);
}

/* File Preview Grid */
.file-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.file-preview-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    position: relative;
    transition: all var(--transition-fast);
}

.file-preview-item:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
    transform: translateY(-2px);
}

.file-preview-thumbnail {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
}

.file-preview-name {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.file-preview-remove {
    position: absolute;
    top: var(--spacing-xs);
    right: var(--spacing-xs);
    width: 24px;
    height: 24px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.file-preview-item:hover .file-preview-remove {
    opacity: 1;
}

/* Progress Indicators */
.progress-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin: var(--spacing-lg) 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.progress-title {
    font-weight: 600;
    color: var(--text-primary);
}

.progress-percentage {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-hover));
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}

/* Toolbar Styles */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0 var(--spacing-md);
    border-right: 1px solid var(--border-color);
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-button {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
}

.toolbar-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toolbar-button.active {
    background: var(--primary-color);
    color: white;
}

.toolbar-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

.toolbar-button:hover .tooltip {
    opacity: 1;
}

/* Properties Panel */
.properties-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
}

.properties-section {
    margin-bottom: var(--spacing-lg);
}

.properties-section:last-child {
    margin-bottom: 0;
}

.properties-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-md);
}

.property-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.property-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 80px;
}

.property-value {
    flex: 1;
}

/* Form Controls */
.form-input,
.form-select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-select {
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

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

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

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

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Keyboard Shortcuts Badge */
.kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: monospace;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 0 var(--border-color);
}

/* Auto-save Indicator */
.auto-save-indicator {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: 0 4px 12px var(--shadow-color);
    opacity: 0;
    transform: translateY(20px);
    transition: all var(--transition-normal);
    z-index: var(--z-notification);
}

.auto-save-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.auto-save-icon {
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

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

.auto-save-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .tool-main {
        padding: var(--spacing-md);
    }
    
    .toolbar {
        padding: var(--spacing-sm);
        gap: var(--spacing-xs);
    }
    
    .toolbar-group {
        padding: 0 var(--spacing-sm);
    }
    
    .file-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .properties-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 50vh;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform var(--transition-normal);
    }
    
    .properties-panel.show {
        transform: translateY(0);
    }
    
    .mobile-toolbar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        padding: var(--spacing-sm);
        display: flex;
        justify-content: space-around;
        z-index: var(--z-dropdown);
    }
    
    .mobile-toolbar-button {
        flex: 1;
        padding: var(--spacing-sm);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        border: none;
        background: none;
        color: var(--text-secondary);
        font-size: 0.75rem;
        cursor: pointer;
        transition: color var(--transition-fast);
    }
    
    .mobile-toolbar-button.active {
        color: var(--primary-color);
    }
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 25%,
        var(--border-color) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Result Preview */
.result-preview {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    max-height: 400px;
    overflow-y: auto;
}

.result-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.result-preview-title {
    font-weight: 600;
    color: var(--text-primary);
}

.result-preview-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.result-preview-content {
    font-family: monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Compare View */
.compare-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
}

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

.compare-panel-header {
    background: var(--bg-tertiary);
    padding: var(--spacing-md);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.compare-panel-content {
    padding: var(--spacing-lg);
    max-height: 500px;
    overflow-y: auto;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: var(--spacing-xs);
}

.zoom-button {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.zoom-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.zoom-value {
    min-width: 60px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Export Options Panel */
.export-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
}

.export-format-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.export-format-option {
    padding: var(--spacing-md);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-format-option:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.export-format-option.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.export-format-icon {
    font-size: 2rem;
    margin-bottom: var(--spacing-sm);
}

.export-format-name {
    font-size: 0.875rem;
    font-weight: 500;
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .toolbar,
    .properties-panel,
    .auto-save-indicator,
    .mobile-toolbar {
        display: none !important;
    }
    
    .tool-container {
        grid-template-columns: 1fr;
    }
    
    .tool-main {
        padding: 0;
    }
}