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

:root {
    --primary-color: #4A478A;
    --primary-dark: #3A356A;
    --secondary-color: #EF4444;
    --secondary-dark: #DC2626;
    --dark-blue: #1D2951;
    --dark-blue-light: #2A3A6B;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --error: #EF4444;
    --success: #10b981;
    --shadow: rgba(0, 0, 0, 0.1);
    --white: #FFFFFF;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--dark-blue);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px var(--shadow);
    overflow: hidden;
}

header {
    background: var(--dark-blue);
    color: var(--white);
    padding: 40px;
    text-align: center;
    position: relative;
}

.user-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    object-fit: cover;
    background: var(--primary-color);
    display: block;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--white);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-transform: none;
    letter-spacing: 0;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.logos-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.icon-wrapper {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.icon-wrapper:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.logo-icon {
    height: 60px;
    width: auto;
    filter: brightness(1.1);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-main {
    height: 50px;
    width: auto;
}

.header-text {
    flex: 1;
    min-width: 300px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

main {
    padding: 40px;
}

section {
    margin-bottom: 40px;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

input[type="file"],
input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--surface);
}

input[type="file"]:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 71, 138, 0.2);
}

input[type="file"] {
    padding: 8px;
    cursor: pointer;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    width: 100%;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(74, 71, 138, 0.4);
}

.btn-process {
    background: var(--secondary-color);
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-process:hover {
    background: var(--secondary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-show-more {
    background: var(--primary-color);
    color: var(--white);
    width: 100%;
    margin-top: 12px;
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-show-more:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 71, 138, 0.3);
}

.file-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    gap: 12px;
}

.file-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.file-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(74, 71, 138, 0.2);
}

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

.file-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.file-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

h2 {
    color: var(--dark-blue);
}

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

.output-item {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--secondary-color);
}

.output-item .file-link {
    color: var(--secondary-dark);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px var(--shadow);
    z-index: 1001;
    display: none;
    animation: slideIn 0.3s ease;
    transition: opacity 0.5s ease;
}

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

.notification.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--error);
}

footer {
    background: var(--dark-blue);
    color: var(--white);
    padding: 20px 40px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

footer a {
    color: var(--white);
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* File Parameters */
.file-params {
    display: flex;
    gap: 15px;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    background: var(--background);
    border-radius: 8px;
    flex-wrap: wrap;
}

.param-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.param-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-icon {
    cursor: help;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.help-icon:hover {
    opacity: 1;
}

.param-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
    display: block;
}

.param-input {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 120px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.param-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 71, 138, 0.1);
}

.param-input[type="number"] {
    width: 100px;
}

/* File Actions */
.file-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-preview {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

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

/* Preview Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    max-width: 90%;
    max-height: 90vh;
    width: 900px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s ease;
}

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

.modal-body {
    padding: 24px;
    overflow: visible;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.preview-info {
    margin-bottom: 20px;
}

.preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    font-size: 0.9rem;
}

.preview-meta span {
    color: var(--text-secondary);
}

.preview-meta strong {
    color: var(--text-primary);
}

.preview-table-container {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    flex: 1;
    min-height: 0;
}

.preview-table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.preview-table-container::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.preview-table-container::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

.preview-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-table thead {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    color: var(--white);
    z-index: 10;
}

.preview-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.preview-table th:last-child {
    border-right: none;
}

.preview-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.preview-table tbody tr:hover {
    background: var(--background);
}

.preview-table td {
    padding: 8px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.preview-table td:hover {
    white-space: normal;
    word-break: break-word;
}

.preview-empty,
.preview-error,
.loading {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.preview-error {
    color: var(--error);
}

/* Preview Search */
.preview-search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.preview-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 71, 138, 0.1);
}

/* Preview Pagination */
.preview-pagination {
    display: none !important; /* Hidden by default, shown via JavaScript for input files only */
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Force hide pagination for output files using data attribute */
.preview-pagination[data-output-file="true"],
.preview-pagination[data-output-file="true"] * {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Additional rule to catch any inline styles */
#previewPagination[data-output-file="true"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

.btn-pagination {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    min-width: 40px;
}

.btn-pagination:hover:not(:disabled) {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.btn-pagination.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    font-weight: 600;
}

.btn-pagination:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.preview-pagination span {
    padding: 0 4px;
    color: var(--text-secondary);
}

/* Statistics Dashboard */
.statistics-section {
    padding: 30px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(74, 71, 138, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(74, 71, 138, 0.4);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Drag and Drop Upload */
.upload-area {
    margin: 20px 0;
}

.upload-dropzone {
    border: 3px dashed var(--border);
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--background);
}

.upload-dropzone:hover {
    border-color: var(--primary-color);
    background: rgba(74, 71, 138, 0.05);
}

.upload-dropzone.drag-over {
    border-color: var(--primary-color);
    background: rgba(74, 71, 138, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* Upload Progress */
.upload-progress-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.upload-progress-item {
    background: var(--background);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.progress-file-name {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 4px;
}

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

/* Suggested Badge */
.suggested-badge {
    display: inline-block;
    background: var(--success);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
}

/* Help Section */
.help-section {
    padding: 30px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.help-section h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-help-toggle {
    background: var(--primary-color);
    color: var(--white);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

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

.help-content {
    margin-top: 20px;
}

.help-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.help-tab {
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.help-tab:hover {
    color: var(--primary-color);
}

.help-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.help-tab-content {
    display: none;
}

.help-tab-content.active {
    display: block;
}

/* FAQ */
.faq-item {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.faq-question {
    padding: 16px;
    background: var(--background);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s ease;
    margin: 0;
}

.faq-question:hover {
    background: rgba(74, 71, 138, 0.05);
}

.faq-toggle {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

.faq-answer {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    color: var(--text-secondary);
    line-height: 1.6;
}

.faq-item.active .faq-answer {
    padding: 16px;
    max-height: 500px;
}

/* Tutorial */
.tutorial-step {
    margin-bottom: 24px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.tutorial-step h3 {
    color: var(--primary-color);
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.tutorial-step p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

@media (max-width: 768px) {
    header {
        padding: 24px;
    }

    header h1 {
        font-size: 2rem;
    }

    .logo-container {
        margin-top: 60px;
    }

    .header-content {
        flex-direction: column;
        gap: 20px;
    }

    .icon-wrapper {
        padding: 12px;
    }

    .logo-icon {
        height: 50px;
    }

    .header-text {
        min-width: auto;
        width: 100%;
    }

    main {
        padding: 24px;
    }

    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .file-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn-process,
    .btn-preview {
        width: 100%;
    }

    .modal-content {
        max-width: 95%;
        max-height: 95vh;
    }

    .preview-meta {
        flex-direction: column;
        gap: 8px;
    }

    footer {
        padding: 16px 24px;
    }

    .user-menu {
        position: static;
        margin-top: 20px;
        justify-content: center;
        flex-wrap: wrap;
    }

    .user-name {
        font-size: 0.85rem;
    }

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

    .upload-dropzone {
        padding: 40px 20px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .help-section {
        padding: 20px;
    }
}

