/* ==================== CSS VARIABLES ==================== */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #111111;
    --bg-surface: #1a1a1a;
    --bg-surface-hover: #232323;
    --border-color: #2a2a2a;
    --brand-500: #8b5cf6;
    --brand-600: #7c3aed;
    --brand-400: #a78bfa;
    --brand-300: #c4b5fd;
    --text-primary: #f5f5f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --sidebar-width: 280px;
    --header-height: 64px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--brand-500);
    border-radius: 10px;
}

/* ==================== HEADER ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    color: var(--text-secondary);
}
.hamburger-btn:hover {
    border-color: var(--brand-500);
    color: var(--brand-400);
    background: var(--bg-surface-hover);
}
.hamburger-btn i {
    font-size: 18px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.logo-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}
.logo-icon i {
    color: white;
    font-size: 16px;
}
.logo-text h1 {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #c084fc, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1;
}
.logo-text span {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 500;
}

.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-badge {
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.header-badge:hover {
    border-color: var(--brand-500);
    color: var(--brand-400);
}
.header-badge .fa-star {
    color: #f59e0b;
    font-size: 10px;
}

/* ==================== SIDEBAR OVERLAY ==================== */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 201;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-header h2 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-header h2 i {
    color: var(--brand-500);
}
.sidebar-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}
.sidebar-close:hover {
    border-color: var(--error);
    color: var(--error);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}
.sidebar-section-title {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 8px 8px;
}
.sidebar-tool {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    margin-bottom: 2px;
}
.sidebar-tool:hover {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.sidebar-tool.active {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--brand-400);
    font-weight: 600;
}
.sidebar-tool .tool-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}
.sidebar-tool.active .tool-icon {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    color: var(--brand-400);
}
.sidebar-tool .tool-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.sidebar-tool .tool-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-tool .tool-desc {
    font-size: 10px;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-top: var(--header-height);
    padding: 24px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-title {
    margin-bottom: 24px;
}
.page-title h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}
.page-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==================== APP GRID ==================== */
.app-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}
@media (min-width: 1024px) {
    .app-grid {
        grid-template-columns: 280px 1fr 300px;
    }
}

/* ==================== CARD ==================== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    transition: all 0.2s;
}
.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}
.card-header i {
    color: var(--brand-500);
    font-size: 14px;
}

/* ==================== SETTINGS ==================== */
.settings-placeholder {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}
.setting-group {
    margin-bottom: 16px;
}
.setting-group:last-child {
    margin-bottom: 0;
}
.setting-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}
.setting-select,
.setting-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
    outline: none;
}
.setting-select:focus,
.setting-input:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.setting-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}
.range-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.range-group input[type="range"] {
    flex: 1;
    accent-color: var(--brand-500);
    height: 4px;
}
.range-value {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-400);
    min-width: 32px;
    text-align: right;
}

/* ==================== DROPZONE ==================== */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-surface);
    position: relative;
}
.dropzone:hover {
    border-color: var(--brand-500);
    background: rgba(139, 92, 246, 0.03);
}
.dropzone.active {
    border-color: var(--brand-500) !important;
    background: rgba(139, 92, 246, 0.08) !important;
    transform: scale(1.01);
}
.dropzone-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(139, 92, 246, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.dropzone-icon i {
    font-size: 28px;
    color: var(--brand-400);
}
.dropzone h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.dropzone p {
    font-size: 12px;
    color: var(--text-muted);
}
.dropzone-browse {
    margin-top: 12px;
    font-size: 11px;
    color: var(--brand-400);
}

/* ==================== TEXT CONTENT ==================== */
.text-input-area {
    width: 100%;
    min-height: 120px;
    padding: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    resize: vertical;
    outline: none;
    transition: all 0.2s;
    margin-top: 12px;
}
.text-input-area:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.text-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ==================== FILE LIST ==================== */
.file-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.file-count-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.file-count-badge span {
    background: var(--brand-500);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
}
.file-actions {
    display: flex;
    gap: 6px;
}
.btn-icon {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    border-color: var(--brand-500);
    color: var(--brand-400);
    background: var(--bg-surface-hover);
}
.btn-icon.active {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: white;
}
.btn-icon.danger:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}
.file-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.file-item:hover {
    border-color: var(--brand-500);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.file-item.list-item {
    flex-direction: row;
    padding: 10px 14px;
    border-radius: 10px;
}
.file-item .file-icon {
    font-size: 28px;
}
.file-item.list-item .file-icon {
    font-size: 20px;
}
.file-item .file-name {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    word-break: break-all;
    line-height: 1.3;
}
.file-item.list-item .file-name {
    flex: 1;
    text-align: left;
    font-size: 12px;
}
.file-item .file-size {
    font-size: 10px;
    color: var(--text-muted);
}
.file-item .file-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: var(--error);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    border: none;
}
.file-item:hover .file-remove {
    opacity: 1;
}
.file-item.list-item .file-remove {
    position: static;
    width: 26px;
    height: 26px;
    opacity: 0;
}
.file-item.list-item:hover .file-remove {
    opacity: 1;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    border: none;
    border-radius: 14px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}
.btn-primary:active {
    transform: scale(0.97);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    padding: 14px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}
.btn-secondary:hover {
    border-color: var(--brand-500);
    background: var(--bg-surface-hover);
}
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.action-buttons .btn-primary {
    flex: 1;
}

/* ==================== PROGRESS ==================== */
.progress-container {
    margin-top: 12px;
}
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.progress-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 10px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
    border-radius: 10px;
    transition: width 0.4s ease;
    width: 0%;
}

/* ==================== PREVIEW ==================== */
.preview-area {
    min-height: 300px;
    background: var(--bg-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.preview-placeholder {
    text-align: center;
    color: var(--text-muted);
}
.preview-placeholder i {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 12px;
}
.preview-placeholder p {
    font-size: 12px;
}
.preview-iframe {
    width: 100%;
    height: 400px;
    border: none;
}
.preview-img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}
.preview-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 10px;
}

/* ==================== STATS ==================== */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
}
.stat-card .stat-value {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #c084fc, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-card .stat-value-success {
    background: linear-gradient(135deg, #10b981, #34d399);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.stat-card .stat-label {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.3s ease;
    pointer-events: auto;
}
.toast.success {
    background: #065f46;
    color: #d1fae5;
    border: 1px solid #059669;
}
.toast.error {
    background: #7f1d1d;
    color: #fecaca;
    border: 1px solid #dc2626;
}
.toast.warning {
    background: #78350f;
    color: #fef3c7;
    border: 1px solid #d97706;
}
.toast.info {
    background: #1e1b4b;
    color: #c7d2fe;
    border: 1px solid #6366f1;
}
.toast .toast-close {
    margin-left: auto;
    cursor: pointer;
    opacity: 0.7;
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
}

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

/* ==================== SPINNER ==================== */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1023px) {
    .app-grid {
        grid-template-columns: 1fr;
    }
    #settingsCard {
        display: none;
    }
    .main-content {
        padding: 16px;
    }
}