/* Universal Converter Styles */
:root {
    --icon-image: #00d4ff;
    --icon-video: #ff6b6b;
    --icon-audio: #ffd93d;
    --icon-extract: #6bcb77;
    --icon-data: #4d96ff;
    --icon-resize: #c77dff;
    --icon-epub: #ff8c42;
    --icon-trim: #00ffb3;
    --icon-pdf: #ff6b6b;
}

.convert-container {
    max-width: 1100px;
    margin: 100px auto 50px;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
}

.section-header {
    order: 0;
    text-align: center;
    margin-bottom: 40px;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.privacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 255, 136, 0.1);
    color: #00ff88;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    margin-top: 20px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

/* Tool Categories */
.tool-categories {
    order: 2;
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* When a work area is active, push categories below and add spacing */
.convert-container.has-active-tool .tool-categories {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.tool-category {
    /* no border, just spacing */
}

.category-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 0 0 14px 2px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.category-title svg {
    opacity: 0.6;
    flex-shrink: 0;
}

/* Tool Cards Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 0;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 10px 40px rgba(0, 212, 255, 0.15);
}

.tool-card:hover::before,
.tool-card.active::before {
    opacity: 1;
}

.tool-card.active {
    border-color: var(--accent-primary);
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.icon-image {
    background: rgba(0, 212, 255, 0.15);
    color: var(--icon-image);
}

.icon-video {
    background: rgba(255, 107, 107, 0.15);
    color: var(--icon-video);
}

.icon-audio {
    background: rgba(255, 217, 61, 0.15);
    color: var(--icon-audio);
}

.icon-extract {
    background: rgba(107, 203, 119, 0.15);
    color: var(--icon-extract);
}

.icon-data {
    background: rgba(77, 150, 255, 0.15);
    color: var(--icon-data);
}

.icon-resize {
    background: rgba(199, 125, 255, 0.15);
    color: var(--icon-resize);
}

.icon-epub {
    background: rgba(255, 140, 66, 0.15);
    color: var(--icon-epub);
}

.icon-trim {
    background: rgba(0, 255, 179, 0.15);
    color: var(--icon-trim);
}

.icon-pdf {
    background: rgba(255, 107, 107, 0.15);
    color: var(--icon-pdf);
}

.tool-card h3 {
    font-size: 1.1rem;
    margin: 0 0 8px;
    color: var(--text-primary);
}

.tool-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.badge {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-edge {
    background: rgba(0, 255, 136, 0.15);
    color: #00ff88;
}

/* Work Area */
.work-area {
    display: none;
    order: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 30px;
    margin-top: 0;
    margin-bottom: 30px;
    position: relative;
}

.work-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-gradient);
    border-radius: 20px 20px 0 0;
}

.work-area.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

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

.work-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.work-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 50px 30px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.05);
}

.drop-zone-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    display: block;
}

.drop-zone h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.drop-zone p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

/* Options Panel */
.options-panel {
    margin-top: 20px;
}

.options-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.file-item .file-icon {
    font-size: 1.5rem;
}

.file-item .file-name {
    font-weight: 500;
    flex: 1;
    word-break: break-all;
}

.file-item .file-size {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

.format-select label,
.quality-slider label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.format-select select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.format-select select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.quality-slider input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 5px;
}

.quality-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.action-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 10px;
}

/* Progress */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

/* Download Area */
.download-area {
    margin-top: 20px;
    text-align: center;
}

.download-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent-gradient);
    color: #0a0a0f;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    margin: 5px;
    transition: all 0.2s ease;
}

.download-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.4);
}

.btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 10px 20px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
}

.btn-reset:hover {
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.05);
}

/* PDF Tool Styles */
.pdf-file-list {
    margin-top: 16px;
}

.pdf-file-list .file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    cursor: grab;
}

.pdf-file-list .file-item:active {
    cursor: grabbing;
}

.pdf-file-list .file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pdf-file-list .file-icon {
    color: var(--icon-pdf);
}

.pdf-file-list .file-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.pdf-file-list .file-size {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.pdf-remove-file {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.15s ease;
}

.pdf-remove-file:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.pdf-help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 8px 0 0 2px;
}

.pdf-page-range {
    margin-top: 16px;
}

.pdf-page-range label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

.text-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.pdf-rotate-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.sortable-ghost {
    opacity: 0.4;
}

/* Data Converter */
.data-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.data-tab {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.data-tab:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.data-tab.active {
    background: var(--accent-primary);
    color: #0a0a0f;
    border-color: var(--accent-primary);
}

#data-input-area textarea,
#data-output-area textarea {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    resize: vertical;
}

#data-input-area textarea:focus,
#data-output-area textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#data-output-area {
    margin-top: 20px;
}

#data-output-area textarea {
    background: rgba(0, 255, 136, 0.05);
    border-color: rgba(0, 255, 136, 0.2);
}

#data-output-area .btn {
    margin-top: 10px;
    margin-right: 10px;
}

/* EPUB Converter Tabs */
.epub-tab {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.epub-tab:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.epub-tab.active {
    background: var(--accent-primary);
    color: #0a0a0f;
    border-color: var(--accent-primary);
    font-weight: 600;
}

/* EPUB Converter */
.epub-meta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.epub-meta-row > div {
    display: flex;
    flex-direction: column;
}

.epub-meta-row input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.epub-meta-row input:hover {
    border-color: rgba(0, 212, 255, 0.3);
}

.epub-meta-row input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.5);
}

.epub-meta-row label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#epub-input {
    width: 100%;
    min-height: 350px;
    padding: 18px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    resize: vertical;
    margin-bottom: 20px;
    transition: all 0.2s;
}

#epub-input:hover {
    border-color: rgba(0, 212, 255, 0.3);
}

#epub-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}

#epub-generate-btn {
    font-size: 1.05rem;
    font-weight: 600;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

#epub-generate-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#epub-generate-btn:hover::before {
    width: 300px;
    height: 300px;
}

/* Image Resizer & Cropper */
#resize-preview-container {
    text-align: center;
    margin-bottom: 20px;
    padding: 0;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    /* Ensure cropper has space */
    min-height: 400px; 
    display: flex;
    align-items: center;
    justify-content: center;
}

#resize-preview {
    max-width: 100%;
    /* max-height removed to let cropper handle it */
    display: block;
}

/* Resize Toolbar */
.resize-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.tool-btn {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tool-btn.active {
    background: var(--accent-primary);
    color: #0a0a0f;
    border-color: var(--accent-primary);
}

/* Inputs Group */
.size-input-group {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.resize-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.size-input input {
    text-align: center;
    font-family: var(--font-mono);
}

.size-link {
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.3;
    transition: opacity 0.2s;
    margin: 0;
}

.size-link.active {
    opacity: 1;
    color: var(--accent-primary);
}

/* Customize Cropper.js look if needed */
.cropper-view-box,
.cropper-face {
    border-radius: 0;
}

.cropper-line,
.cropper-point {
    background-color: var(--accent-primary);
}

/* ==========================================
   VIDEO TRIM STYLES
   ========================================== */

.trim-preview-container {
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.trim-preview-container video {
    width: 100%;
    max-height: 300px;
    display: block;
    object-fit: contain;
}

/* Filmstrip bar */
.trim-bar-wrapper {
    margin-bottom: 20px;
}

.trim-time-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: 0.01em;
}

#trim-duration-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.trim-bar {
    position: relative;
    height: 72px;
    border-radius: 10px;
    overflow: hidden;
    background: #111;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
}

#trim-filmstrip-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: block;
}

.trim-overlay-left,
.trim-overlay-right {
    position: absolute;
    top: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.58);
    z-index: 2;
    pointer-events: none;
}

.trim-overlay-left { left: 0; }
.trim-overlay-right { right: 0; }

/* Selection box: yellow top+bottom border, handles on sides */
.trim-selection {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 3;
    border-top: 3px solid #FFD60A;
    border-bottom: 3px solid #FFD60A;
    box-sizing: border-box;
    pointer-events: none;
}

/* Handles */
.trim-handle {
    position: absolute;
    top: 0; bottom: 0;
    width: 22px;
    background: #FFD60A;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: ew-resize;
    pointer-events: all;
}

.trim-handle:active {
    background: #e6c400;
}

.trim-handle svg {
    color: rgba(0, 0, 0, 0.65);
    flex-shrink: 0;
}

.trim-handle-left {
    left: 0;
    border-radius: 5px 0 0 5px;
}

.trim-handle-right {
    right: 0;
    border-radius: 0 5px 5px 0;
}

/* Playhead */
.trim-playhead {
    position: absolute;
    top: 4px; bottom: 4px;
    width: 2px;
    background: white;
    z-index: 5;
    pointer-events: none;
    transform: translateX(-50%);
    border-radius: 2px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

/* Loading overlay */
.trim-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-radius: 10px;
    letter-spacing: 0.02em;
}

/* Mute toggle */
.trim-mute-option {
    display: flex;
    align-items: center;
}

.trim-toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}

.trim-toggle-label input[type="checkbox"] {
    display: none;
}

.trim-toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 11px;
    transition: background 0.2s;
    border: 1px solid var(--border-color);
}

.trim-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: left 0.2s, background 0.2s;
}

.trim-toggle-label input:checked + .trim-toggle-track {
    background: rgba(0, 255, 179, 0.2);
    border-color: var(--icon-trim);
}

.trim-toggle-label input:checked + .trim-toggle-track .trim-toggle-thumb {
    left: 21px;
    background: var(--icon-trim);
}

/* Responsive */
@media (max-width: 768px) {
    .convert-container {
        margin-top: 80px;
        padding: 20px 15px;
    }

    .section-title {
        font-size: 1.8rem;
    }

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

    .options-row {
        grid-template-columns: 1fr;
    }

    .work-area {
        padding: 20px;
    }

    .drop-zone {
        padding: 40px 20px;
    }

    .data-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .resize-controls {
        flex-direction: column;
    }

    .size-link {
        transform: rotate(90deg);
        margin: 10px 0;
    }

    .epub-meta-row {
        grid-template-columns: 1fr;
        padding: 15px;
    }

    #epub-input {
        min-height: 250px;
        font-size: 0.9rem;
    }
}