* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.info-message {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.info-message summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 25px;
    cursor: pointer;
    user-select: none;
}

.info-message summary::-webkit-details-marker {
    display: none;
}

.info-message summary::after {
    content: '▾';
    font-size: 1.2rem;
    color: #1976d2;
    transition: transform 0.2s ease;
}

.info-message[open] summary::after {
    transform: rotate(-180deg);
}

.info-message h3 {
    color: #1976d2;
    font-size: 1.2rem;
    margin: 0;
}

.info-content {
    padding: 0 25px 20px 25px;
}

.info-message p {
    color: #555;
    margin-bottom: 10px;
    line-height: 1.6;
}

.info-message p:last-child {
    margin-bottom: 0;
}

.ocr-note {
    font-size: 0.85rem;
    color: #777;
    font-style: italic;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #1976d2;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.github-link:hover {
    color: #0d47a1;
    text-decoration: underline;
}

.github-icon {
    fill: currentColor;
    vertical-align: middle;
    transition: transform 0.2s;
}

.github-link:hover .github-icon {
    transform: scale(1.1);
}

.content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

/* ============ TÉRMINOS ============ */

.add-term {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.add-term-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-term-inputs {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    margin-bottom: 12px;
}

#termInput {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

#termInput:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

#colorInput {
    width: 50px;
    height: 45px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.3s;
}

#colorInput:hover {
    border-color: #2196f3;
}

.border-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    cursor: pointer;
    user-select: none;
}

.border-checkbox input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

.border-checkbox span {
    font-size: 0.9rem;
    color: #555;
    white-space: nowrap;
}

.icon-upload {
    border: 1px dashed #bcd4f6;
    border-radius: 8px;
    padding: 12px 16px;
    background: rgba(33, 150, 243, 0.05);
    display: grid;
    gap: 10px;
    margin-bottom: 15px;
}

.icon-upload-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a4d8f;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.icon-upload-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#iconInput {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
}

#iconInput:hover {
    border-color: #2196f3;
}

.btn-clear-icon {
    padding: 8px 14px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.4);
    color: #c62828;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear-icon:hover {
    background: rgba(244, 67, 54, 0.18);
}

.icon-preview {
    font-size: 0.85rem;
    color: #555;
    background: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    border: 1px solid #d6e0f0;
}

.icon-preview.has-icon {
    color: #1b5e20;
    border-color: #a5d6a7;
    background: #e8f5e9;
}

#addTermBtn {
    width: 100%;
    padding: 12px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#addTermBtn:hover {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.no-terms {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
    width: 100%;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #ddd;
}

.term-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 20px;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.term-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.term-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.term-icon-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(103, 58, 183, 0.1);
    border: 1px solid rgba(103, 58, 183, 0.2);
    padding: 4px;
}

.term-icon-img {
    max-width: 20px;
    max-height: 20px;
}

.term-text {
    font-size: 0.95rem;
    color: #333;
    font-weight: 500;
}

.term-border-indicator {
    font-size: 0.75rem;
    color: #666;
    background: rgba(0,0,0,0.05);
    padding: 2px 8px;
    border-radius: 10px;
}

.delete-btn {
    width: 24px;
    height: 24px;
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: #dc3545;
    color: white;
    transform: rotate(90deg);
}

.config-management {
    margin-top: 30px;
    display: block;
    border: 1px solid #d7e1f5;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(236, 242, 255, 0.9) 0%, rgba(226, 235, 252, 0.9) 100%);
    box-shadow: 0 8px 26px rgba(21, 60, 120, 0.12);
    overflow: hidden;
}

.config-management summary {
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 22px;
    cursor: pointer;
    font-weight: 700;
    color: #1e3054;
    font-size: 0.95rem;
    user-select: none;
}

.config-management summary::-webkit-details-marker {
    display: none;
}

.config-management summary::after {
    content: '▾';
    font-size: 1rem;
    color: #1e4ba8;
    transition: transform 0.2s ease;
}

.config-management[open] summary::after {
    transform: rotate(-180deg);
}

.config-management[open] summary {
    border-bottom: 1px solid rgba(30, 75, 168, 0.08);
    background: rgba(30, 75, 168, 0.05);
}

.config-summary-meta {
    font-size: 0.75rem;
    color: #335177;
    background: rgba(30, 75, 168, 0.16);
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
}

.config-save,
.config-list-section {
    background: transparent;
    padding: 18px 22px;
    border-top: 1px solid rgba(30, 75, 168, 0.06);
}

.config-db-download {
    padding: 18px 22px 12px;
    border-top: 1px solid rgba(30, 75, 168, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.config-db-note {
    margin: 0;
    font-size: 0.85rem;
    color: #1e3054;
    text-align: center;
}

.config-save-header,
.config-list-header {
    font-size: 0.95rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-save-controls {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 10px;
}

#configNameInput {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

#configNameInput:focus {
    outline: none;
    border-color: #673ab7;
    box-shadow: 0 0 0 3px rgba(103, 58, 183, 0.1);
}

#saveConfigBtn {
    padding: 12px 20px;
    background: #673ab7;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

#saveConfigBtn:hover:not(:disabled) {
    background: #5e35b1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(103, 58, 183, 0.25);
}

#saveConfigBtn:disabled {
    background: #c5cae9;
    color: #eee;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.config-hint,
.config-delete-note {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.config-delete-note {
    margin-top: 12px;
    font-style: italic;
}

.configurations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.no-configs {
    text-align: center;
    color: #777;
    font-style: italic;
    padding: 16px;
    border: 1px dashed #d0d4da;
    border-radius: 8px;
    background: rgba(103, 58, 183, 0.05);
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.config-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-name {
    font-weight: 600;
    color: #333;
}

.config-meta {
    font-size: 0.85rem;
    color: #777;
}

.config-actions {
    display: flex;
    gap: 10px;
}

.config-load-btn,
.config-delete-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.config-load-btn {
    background: #4caf50;
    color: white;
}

.config-load-btn:hover {
    background: #43a047;
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.25);
}

.config-delete-btn {
    background: rgba(244, 67, 54, 0.12);
    color: #f44336;
}

.config-delete-btn:hover {
    background: rgba(244, 67, 54, 0.2);
    box-shadow: 0 4px 10px rgba(244, 67, 54, 0.2);
}

/* ============ PDF SECTION ============ */

.upload-area {
    border: 3px dashed #ccc;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-label {
    cursor: pointer;
    display: block;
}

.upload-label span {
    font-size: 1.2rem;
    color: #666;
}

.pdf-info {
    background: #e7f3ff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.pdf-info p {
    margin-bottom: 10px;
    color: #333;
    font-size: 1rem;
}

.pdf-info p:last-of-type {
    margin-bottom: 20px;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ============ PROGRESS ============ */

.progress {
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 15px;
}

#progressText {
    text-align: center;
    color: #666;
    font-weight: 500;
}

/* ============ RESULT SECTION ============ */

.result-section {
    background: #d4edda;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
}

.result-section h3 {
    color: #155724;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-success,
.btn-secondary,
.btn-view,
.btn-reset {
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-view {
    background: #667eea;
    color: white;
}

.btn-view:hover {
    background: #5568d3;
}

.btn-reset {
    background: #ffc107;
    color: #333;
}

.btn-reset:hover {
    background: #e0a800;
}

/* ============ PDF VIEWER ============ */

.pdf-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.app-footer {
    text-align: center;
    font-size: 0.85rem;
    color: #4a5568;
    margin: 24px 0 12px;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.viewer-title-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.viewer-header h2 {
    color: white;
    margin: 0;
    font-size: 1.5rem;
}

.term-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 12px;
    border-radius: 6px;
}

.stat-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pages-list {
    font-size: 0.85rem;
    opacity: 0.8;
    font-weight: normal;
}

.no-results {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    font-size: 0.9rem;
}

.ocr-warning {
    display: block;
    color: #ffc107;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255, 193, 7, 0.15);
    border-radius: 6px;
    border-left: 3px solid #ffc107;
}

.btn-close {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-close:hover {
    background: #c82333;
}

.viewer-content {
    flex: 1;
    padding: 20px;
    overflow: hidden;
}

#pdfFrame {
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
}

/* ============ FILES LIST ============ */

.files-list {
    margin: 15px 0;
    max-height: 200px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
}

.file-name {
    font-weight: 500;
    color: #333;
    flex: 1;
}

.file-size {
    color: #666;
    font-size: 0.9rem;
}

/* ============ QUEUE PROGRESS ============ */

.queue-progress {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.queue-progress h3 {
    color: #333;
    margin-bottom: 15px;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
}

.queue-item.pending {
    border-color: #ffc107;
    background: #fff9e6;
}

.queue-item.processing {
    border-color: #2196f3;
    background: #e3f2fd;
    animation: pulse 1.5s ease-in-out infinite;
}

.queue-item.completed {
    border-color: #4caf50;
    background: #e8f5e9;
}

.queue-item.error {
    border-color: #f44336;
    background: #ffebee;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.queue-status {
    font-size: 1.5rem;
    line-height: 1;
}

.queue-filename {
    flex: 1;
    font-weight: 500;
    color: #333;
}

.queue-progress {
    font-size: 0.9rem;
    color: #666;
    min-width: 200px;
}

.file-progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 5px;
}

.file-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-text {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
}

/* ============ RESULTS LIST ============ */

.results-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #4caf50;
    transition: all 0.3s;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.result-item.error {
    border-color: #f44336;
    background: #ffebee;
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.result-name {
    font-weight: 600;
    color: #333;
}

.result-stats {
    font-size: 0.9rem;
    color: #666;
}

.result-error {
    font-size: 0.9rem;
    color: #f44336;
}

.ocr-badge {
    display: inline-block;
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.btn-view-single {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-view-single:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

.btn-download-single {
    padding: 8px 16px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-download-single:hover {
    background: #45a049;
    transform: translateY(-1px);
}

/* ============ UTILITY ============ */

.hidden {
    display: none !important;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .content {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2rem;
    }

    .add-term-inputs {
        grid-template-columns: 1fr;
    }

    .border-checkbox {
        justify-content: center;
    }

    #colorInput {
        width: 100%;
        height: 50px;
    }

    .viewer-header {
        padding: 15px 20px;
    }

    .viewer-header h2 {
        font-size: 1.2rem;
    }

    .viewer-content {
        padding: 10px;
    }

    .terms-list {
        justify-content: center;
    }

    .config-save-controls {
        grid-template-columns: 1fr;
    }

    #saveConfigBtn {
        width: 100%;
    }

    .config-item {
        flex-direction: column;
        align-items: stretch;
    }

    .config-actions {
        width: 100%;
        justify-content: space-between;
    }

    .config-load-btn,
    .config-delete-btn {
        flex: 1;
    }

    .icon-upload-controls {
        flex-direction: column;
        align-items: stretch;
    }

    #iconInput,
    .btn-clear-icon {
        width: 100%;
    }
}
