/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 25%, #4e79a7 50%, #63a4e0 75%, #7daee0 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Tabs */
.tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 5px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    color: white;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-button.active {
    background: white;
    color: #0b74b7;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.upload-area {
    border: 3px dashed #2b8cc4;
    border-radius: 15px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9ff;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #2b8cc4;
    background: #f0f2ff;
}

.upload-area.dragover {
    border-color: #1f6a92;
    background: #e6f3ff;
    transform: scale(1.02);
}

.upload-area i {
    font-size: 3rem;
    color: #2b8cc4;
    margin-bottom: 15px;
}

.upload-area p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 20px;
}

.upload-btn {
    background: #2b8cc4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

.upload-btn:hover {
    background: #046fae;
}


.upload-hint {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

/* Password Section */
.password-section {
    margin-bottom: 20px;
}

.password-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

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

.password-input-group {
    position: relative;
    flex: 1;
}

.password-input-group input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.password-input-group input:focus {
    outline: none;
    border-color: #0b74b7;
    box-shadow: 0 0 0 3px rgba(11, 116, 183, 0.1);
}


.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    transition: color 0.3s ease;
}

.toggle-password:hover {
    color: #0b74b7;
}

.generate-password-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

.generate-password-btn:hover {
    background: linear-gradient(135deg, #38a169, #2f855a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.4);
}

/* Process Button */
.process-btn {
    width: 100%;
    background: #0b74b7;
    color: white;
    border: none;
    padding: 15px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.process-btn:hover:not(:disabled) {
    background: #065f93;
    transform: translateY(-2px);
}

.process-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* Preview Section */
.preview-section {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
    text-align: center;
}

.preview-section h3 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

/* File List - Horizontal Scrollable Thumbnail Row */
.file-list {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0 40px 0;
    margin: 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #9ca3af #f1f1f1;
}

.file-list::-webkit-scrollbar {
    height: 8px;
}

.file-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

.file-list::-webkit-scrollbar-thumb:hover {
    background: #065f93;
}

/* Individual File Thumbnail */
.file-preview {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Thumbnail Images */
.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* Thumbnail Videos */
.file-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    pointer-events: none;
    /* Prevent video controls in thumbnail */
}

/* File type indicator overlay */
.file-preview .file-type-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* File name tooltip */
.file-preview .file-name {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 100;
    max-width: 200px;
    text-overflow: ellipsis;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.file-preview:hover .file-name {
    opacity: 1;
}

/* Hide filename tooltip on decoded preview to prevent overflow issues */
.decoded-preview .file-preview .file-name {
    display: none;
}

/* Result Section */
.result-section {
    margin-top: 30px;
    padding: 25px;
    background: #f0fff4;
    border-radius: 10px;
    border-left: 5px solid #48bb78;
}

#encode-result {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.result-section h3 {
    margin-bottom: 20px;
    color: #2d3748;
}

.encoded-info,
.decoded-info {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.encoded-info p,
.decoded-info p {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.status-success {
    color: #28a745;
}

.status-error {
    color: #dc3545 !important;
}

.download-btn {
    background: #2b8cc4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(43, 140, 196, 0.3);
}

.download-btn:hover {
    background: #046fae;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(43, 140, 196, 0.4);
}

/* center only the download button without changing info alignment */
#encode-result .download-btn {
    display: block;
    margin: 0 auto;
    align-self: auto;
}

/* ensure info boxes stay full width and left-aligned */
.encoded-info,
.decoded-info {
    width: 100%;
    text-align: left;
}

/* Security Info */
.security-info {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.security-info h3 {
    color: #2d3748;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.security-info ul {
    list-style: none;
}

.security-info li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4a5568;
}

.security-info li i {
    color: #48bb78;
}

#original-preview {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0;
    margin: 0;
    scroll-behavior: smooth;
}

/* Decoded Preview - Same horizontal layout */
.decoded-preview {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0;
    margin: 20px 0;
    scroll-behavior: smooth;
}

.decoded-preview .file-preview {
    flex: 0 0 120px;
    width: 120px;
    height: 120px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.decoded-preview img,
.decoded-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

/* Clean file upload status indicator */
.upload-status {
    margin: 20px 0;
    background: linear-gradient(135deg, #f0fdf4 0%, #f8fffe 100%);
    border: 1px solid #d1fae5;
    border-radius: 12px;
    padding: 16px;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.status-message {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #047857;
    font-weight: 600;
    margin-bottom: 2px;
}

.status-icon {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.file-toggle {
    margin-top: 12px;
    padding: 8px 12px;
    color: #059669;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: all 0.2s ease;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 8px;
    border: 1px solid transparent;
}

.file-toggle:hover {
    color: #047857;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.chevron {
    transition: transform 0.3s ease;
    font-size: 14px;
    font-weight: bold;
    color: #059669;
}

.chevron.open {
    transform: rotate(180deg);
}

.uploaded-files {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(16, 185, 129, 0.2);
}

.file-entry {
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
    color: #374151;
    border-left: 3px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.file-entry:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-entry:last-child {
    margin-bottom: 0;
}

.file-entry.secure {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4, #ffffff);
}

.file-entry.chunk {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #f0f9ff, #ffffff);
}

/* Download all files button */
.decoded-actions {
    margin: 16px 0;
    text-align: center;
}

.download-btn {
    background: #2b8cc4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(43, 140, 196, 0.3);
}

.download-btn:hover {
    background: #046fae;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(43, 140, 196, 0.4);
}

/* File icon previews for non-media files */
.file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border-radius: 8px;
    position: relative;
}

.file-icon i {
    z-index: 1;
}

.audio-icon {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.pdf-icon {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.text-icon {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
}

.generic-icon {
    background: linear-gradient(135deg, #6b7280, #4b5563);
    color: white;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    /* keep modal bounded and centered so it doesn't push thumbnails */
    width: min(900px, 80vw);
    max-width: 90%;
    max-height: 85vh;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    color: #475569;
    font-size: 16px;
    cursor: pointer;
    z-index: 1002;
    background: rgba(255, 255, 255, 0.95);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(71, 85, 105, 0.06);
}

.modal-close i {
    font-size: 14px;
}

.modal-close:hover {
    background: white;
    color: #2b6cb0;
}

/* Navigation buttons */
.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    background: rgba(255, 255, 255, 0.9);
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(71, 85, 105, 0.06);
    cursor: pointer;
}

.modal-prev {
    left: 12px;
}

.modal-next {
    right: 12px;
}

.modal-nav i {
    font-size: 14px;
    color: #334155;
}

.modal-nav:hover {
    background: white;
    color: #2b6cb0;
}

.modal-body {
    padding: 20px;
    text-align: center;
}

#modal-image,
#modal-video {
    /* keep media comfortably inside the modal and centered */
    display: block;
    margin: 0 auto;
    max-width: calc(100% - 40px);
    max-height: calc(80vh - 80px);
    border-radius: 10px;
}

#modal-video {
    background: #000;
}

#modal-video::-webkit-media-controls-panel {
    background-color: rgba(0, 0, 0, 0.8);
}

#modal-file-info {
    margin-top: 15px;
}

#modal-filename {
    color: #333;
    margin-bottom: 10px;
}

#modal-filesize {
    color: #666;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .tab-content {
        padding: 20px;
    }

    .upload-area {
        padding: 30px 15px;
    }

    .upload-area i {
        font-size: 2.5rem;
    }

    .progress-container {
        min-width: 280px;
        margin: 0 15px;
    }

    .password-controls {
        flex-direction: column;
        gap: 15px;
    }

    .password-input-group,
    .generate-password-btn {
        width: 100%;
    }

    .generate-password-btn {
        justify-content: center;
    }

    /* Keep horizontal scrolling on mobile for thumbnails */
    .file-list,
    #original-preview,
    .decoded-preview {
        gap: 10px;
        padding: 10px 0 30px 0;
    }

    .file-preview {
        flex: 0 0 100px;
        width: 100px;
        height: 100px;
    }

    .decoded-preview .file-preview {
        flex: 0 0 100px;
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .file-list #original-preview .decoded-preview {
        gap: 8px;
        padding: 8px 0 25px 0;
    }

    .file-preview {
        flex: 0 0 80px;
        width: 80px;
        height: 80px;
    }

    .decoded-preview .file-preview {
        flex: 0 0 80px;
        width: 80px;
        height: 80px;
    }
}