* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #2d3561 100%);
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    padding: 20px 30px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    color: #333;
    font-weight: 700;
    font-size: 28px;
    text-align: center;
    flex: 1;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f0f0f0;
    transform: none;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* File Upload Section */
.file-upload-section {
    max-width: 900px;
    margin: 0 auto;
}

.file-upload-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.file-upload-box {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
}

.file-upload-box:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.file-upload-box.drag-over {
    border-color: #667eea;
    background: #e3f2fd;
    transform: scale(1.02);
}

.file-upload-box.loaded {
    border-color: #4caf50;
    background: #e8f5e9;
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.file-upload-box h3 {
    color: #333;
    margin-bottom: 10px;
    font-weight: 400;
}

.upload-instruction {
    color: #666;
    font-size: 14px;
    margin-bottom: 10px;
}

.file-name {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
    word-break: break-all;
    margin-top: 10px;
    min-height: 20px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-primary {
    padding: 15px 40px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 15px 40px;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-secondary:hover:not(:disabled) {
    background: #f0f4ff;
    transform: translateY(-2px);
}

.btn-secondary:disabled {
    border-color: #ccc;
    color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Diff View Section */
.diff-view-section {
    max-width: 100%;
    margin-top: 30px;
}

.diff-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.diff-stats {
    font-size: 14px;
    color: #666;
}

.view-options {
    display: flex;
    gap: 5px;
}

.view-toggle {
    padding: 8px 16px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
}

.view-toggle:hover {
    border-color: #667eea;
    transform: none;
}

.view-toggle.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.view-toggle:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #ddd;
}

.view-toggle:disabled:hover {
    border-color: #ddd;
    transform: none;
}

/* Diff Content */
.diff-content {
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow-x: auto;
    background: #fff;
}

.diff-content.no-wrap .diff-table td {
    white-space: nowrap;
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.diff-table td {
    padding: 2px 10px;
    vertical-align: top;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.line-number {
    color: #999;
    text-align: right;
    user-select: none;
    width: 50px;
    border-right: 1px solid #ddd;
    padding-right: 10px !important;
}

.line-added {
    background: #e6ffed;
}

.line-deleted {
    background: #ffebe9;
}

.line-modified {
    background: #fff8c5;
}

.line-moved-from,
.line-moved-to {
    background: #fff4cc;
}

.line-unchanged {
    background: #fff;
}

.move-indicator {
    color: #c69026;
    font-weight: bold;
    margin-right: 8px;
    display: inline-block;
    width: 16px;
    text-align: center;
}

.diff-marker {
    color: #666;
    user-select: none;
    padding-right: 10px;
}

/* Unified View */
.unified-view .line-added .diff-marker {
    color: #22863a;
}

.unified-view .line-deleted .diff-marker {
    color: #cb2431;
}

/* Footer */
.app-footer {
    padding: 15px;
    text-align: center;
    border-top: 2px solid #f0f0f0;
    font-size: 14px;
}

.app-footer a {
    color: #667eea;
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #333;
    font-weight: 400;
    font-size: 22px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.close-btn:hover {
    background: #f0f0f0;
    color: #333;
    transform: none;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #666;
}

.modal-body h3 {
    color: #333;
    font-weight: 500;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 16px;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
    color: #666;
}

.modal-body li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.version {
    font-size: 12px;
    color: #999;
    margin-top: 20px !important;
}

.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: flex;
    align-items: center;
    color: #333;
    cursor: pointer;
}

.option-group input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.option-group input[type="number"] {
    padding: 5px 10px;
    border: 2px solid #eee;
    border-radius: 5px;
    font-size: 14px;
}

.option-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.option-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.option-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 15px;
    margin-top: 0;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 2px solid #f0f0f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #f0f0f0;
}

.modal-buttons button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-cancel {
    background: #666;
    color: white;
}

.modal-cancel:hover {
    background: #555;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .file-upload-container {
        grid-template-columns: 1fr;
    }

    .diff-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons button {
        width: 100%;
    }
}

/* Floating Scrollbar */
.floating-scrollbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, 0.95);
    border-top: 2px solid #667eea;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: 0;
}

.floating-scrollbar-content {
    height: 1px;
    display: inline-block;
}

/* Binary Hex View */
.binary-hex-view {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
}

.binary-hex-view thead {
    background: #f8f9fa;
    border-bottom: 2px solid #ddd;
    position: sticky;
    top: 0;
    z-index: 10;
}

.binary-hex-view th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: #333;
}

.hex-offset {
    color: #999;
    text-align: right;
    width: 100px;
    padding-right: 20px !important;
    font-weight: normal;
}

.hex-bytes {
    width: 35%;
    padding: 5px 10px !important;
    font-family: 'Consolas', 'Monaco', monospace;
}

.file-size {
    font-size: 11px;
    color: #999;
    font-weight: normal;
    margin-left: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.hex-ascii {
    width: 20%;
    padding: 5px 10px !important;
    color: #666;
}

.hex-byte {
    display: inline-block;
    margin-right: 2px;
}

.hex-changed {
    background: #ffcccc;
    color: #c00;
    border-radius: 2px;
}

.hex-missing {
    color: #ccc;
}

.hex-row-changed {
    background: #fffef0;
}

.hex-row-added {
    background: #e6ffed;
}

.hex-row-deleted {
    background: #ffeef0;
}

.hex-row-unchanged {
    background: #fff;
}

.ascii-col {
    display: inline-block;
    font-family: 'Consolas', 'Monaco', monospace;
}

.ascii-separator {
    display: inline-block;
    margin: 0 10px;
    color: #999;
}

.ascii-changed {
    background-color: #ffcccc;
    color: #d00;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Hide ASCII column when hide-ascii class is applied */
#diffContent.hide-ascii .hex-ascii,
#diffContent.hide-ascii .binary-hex-view thead th:nth-child(4) {
    display: none;
}

/* Hide offset column when hide-offsets class is applied */
#diffContent.hide-offsets .hex-offset,
#diffContent.hide-offsets .binary-hex-view thead th:nth-child(1) {
    display: none;
}

/* Progress Modal */
.progress-modal {
    z-index: 2000;
}

.progress-modal-content {
    max-width: 500px;
    padding: 0;
}

.progress-header {
    background: #667eea;
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    text-align: center;
}

.progress-header h3 {
    margin: 0;
    font-size: 20px;
}

.progress-body {
    padding: 30px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar {
    height: 100%;
    background: #667eea;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.progress-message {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.progress-details {
    font-size: 13px;
    color: #666;
    text-align: center;
    min-height: 20px;
    margin-bottom: 20px;
}

.progress-cancel-btn {
    width: 100%;
    padding: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.progress-cancel-btn:hover {
    background: #c82333;
}
