/* Gnosis OCR-S Styles */

:root {
    --primary: #4ade80; /* terminal-green */
    --primary-dark: #22c55e;
    --secondary: #10b981;
    --danger: #ef4444;
    --dark: #111827; /* bg-gray-900 */
    --gray: #6b7280;
    --light-gray: #1f2937; /* bg-gray-800 */
    --white: #e5e7eb; /* text-gray-200 */
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'JetBrains Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--dark);
    color: var(--white);
    line-height: 1.6;
}

/* Header */
.header {
    background: var(--dark);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #374151; /* gray-700 */
}

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

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Glitch effect for Gn0iS title */
@keyframes glitch {
    0%, 100% { transform: translate(0); filter: hue-rotate(0deg); }
    10% { transform: translate(-2px, 2px); filter: hue-rotate(90deg); }
    20% { transform: translate(2px, -2px); filter: hue-rotate(180deg); }
    30% { transform: translate(-2px, -2px); filter: hue-rotate(270deg); }
    40% { transform: translate(2px, 2px); filter: hue-rotate(360deg); }
    50% { transform: translate(0); filter: hue-rotate(0deg); }
}

.gnosis-title {
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary), 0 0 20px var(--primary), 0 0 30px var(--primary);
    cursor: pointer;
    user-select: none;
}

.gnosis-title:hover, .gnosis-title.glitch-active {
    animation: glitch 0.3s infinite;
}


.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--gray);
    font-size: 0.875rem;
}

/* Main Content */
.main {
    min-height: calc(100vh - 80px);
    padding: 2rem 0;
}

.upload-section {
    background: var(--light-gray);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid #374151;
}

.upload-area {
    border: 2px dashed var(--gray);
    border-radius: 0.5rem;
    padding: 3rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    background-color: var(--dark);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background-color: rgba(74, 222, 128, 0.05);
}

.upload-area.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.upload-area.disabled:hover {
    border-color: var(--gray);
    background-color: var(--dark);
}


.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    fill: none;
    stroke: var(--gray);
}

.upload-text {
    color: var(--gray);
    margin-bottom: 1rem;
}

.upload-button {
    background: var(--primary);
    color: var(--dark);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-button:hover {
    background: var(--primary-dark);
}

#file-input {
    display: none;
}

.file-types {
    font-size: 0.75rem;
    color: var(--gray);
    margin-top: 1rem;
}

/* Upload Options */
.upload-options {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
    background: var(--dark);
    border-radius: 0.375rem;
}

.upload-info {
    font-size: 0.875rem;
    color: var(--gray);
    display: none; /* Hidden as requested */
}

.checkbox-label {
    display: none; /* Hidden as requested */
}

/* Model Display Box */
.model-selection-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.model-selection-wrapper label {
    font-weight: 500;
    color: var(--gray);
}

.model-display-box {
    background-color: var(--primary);
    color: var(--dark);
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: bold;
    text-align: center;
}



/* Upload Progress */
.upload-progress {
    display: none;
    margin-top: 2rem;
}

.progress-bar {
    background: var(--dark);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

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

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

/* Sessions Section */
.sessions-section {
    background: var(--light-gray);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid #374151;
}

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

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

.clear-sessions {
    background: var(--danger);
    color: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.clear-sessions:hover {
    background: #dc2626;
}

/* Session List */
.session-list {
    display: grid;
    gap: 1rem;
}

.session-item {
    border: 1px solid #374151;
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    cursor: pointer;
    background-color: var(--dark);
}

.session-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.session-info {
    flex: 1;
}

.session-filename {
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--white);
}

.session-meta {
    font-size: 0.875rem;
    color: var(--gray);
}

.session-status {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-completed {
    background: #10b981;
    color: var(--dark);
}

.status-processing {
    background: #3b82f6;
    color: var(--white);
    display: inline-flex;
    align-items: center;
}

.status-uploaded {
    background: #4b5563;
    color: var(--white);
}

.status-ready_for_ocr {
    background: #f59e0b;
    color: var(--dark);
}


.status-error {
    background: #ef4444;
    color: var(--white);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
}

.empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    fill: none;
    stroke: var(--gray);
    opacity: 0.5;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 2rem;
}

.modal-content {
    background: var(--light-gray);
    color: var(--white);
    max-width: 900px;
    margin: 0 auto;
    border-radius: 0.5rem;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid #374151;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
}

.close-button:hover {
    color: var(--white);
}

/* Session Details */
.session-details {
    padding: 1rem;
}

.session-details p {
    margin-bottom: 0.75rem;
}

.session-details strong {
    color: var(--white);
}

.file-link {
    text-decoration: none;
    display: inline-block;
    margin-top: 1.5rem;
}

/* Action Button */
.action-button {
    background: var(--primary);
    color: var(--dark);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.action-button:hover:not(:disabled) {
    background: var(--primary-dark);
}

.action-button.disabled,
.action-button:disabled {
    background: var(--gray);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading Spinner */
.spinner {
    border: 2px solid var(--light-gray);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 0.5rem;
}

/* Small spinner for inline use */
.spinner-small {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(74, 222, 128, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 0.5rem;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Modal Variations */
.modal-error .modal-header {
    color: var(--danger);
}

.modal-success .modal-header {
    color: var(--secondary);
}

.modal-progress .modal-content {
    max-width: 400px;
}

/* Modal Progress */
.modal-progress {
    padding: 1rem 0;
}

.progress-message {
    margin-bottom: 1rem;
    text-align: center;
}

.modal-progress .progress-bar {
    background: var(--dark);
    height: 20px;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1rem;
}

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

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

/* Modal Confirm */
.modal-confirm p {
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.cancel-button {
    background: var(--gray);
    color: var(--white);
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.375rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.cancel-button:hover {
    background: #4b5563;
}



/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .upload-area {
        padding: 2rem;
    }
    
    .upload-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .session-item {
        flex-direction: column;
        align-items: stretch; /* Make items take full width */
        gap: 1rem; /* Add gap between vertical items */
    }

    .session-actions {
        display: flex;
        flex-direction: column; /* Stack buttons vertically */
        align-items: stretch; /* Make buttons full-width */
        width: 100%; /* Ensure it takes full width of the card */
        gap: 0.5rem;
    }

    .session-actions .action-button,
    .session-actions .session-status {
        text-align: center; /* Center text in buttons/status */
    }

    .session-filename {
        word-break: break-all;
    }
}

.modal-body {
    padding: 20px;
    line-height: 1.6;
}

.ocr-results-container {
    margin-top: 20px;
    border-top: 1px solid #374151;
    padding-top: 15px;
}

.ocr-results-container h3 {
    margin-bottom: 10px;
    font-size: 1.2em;
}

.ocr-results {
    max-height: 300px;
    overflow-y: auto;
    background: var(--dark);
    border: 1px solid #374151;
    padding: 10px;
    border-radius: 4px;
}

.ocr-page {
    margin-bottom: 15px;
}

.ocr-page h4 {
    margin-bottom: 5px;
    font-size: 1em;
    font-weight: bold;
}

.ocr-page pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #000;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #374151;
}
