/* =====================================================
   TSV to PDF - CSS (مستوحى من تصميم DonePDF)
   متوافق مع هيكل TSV to PDF
   ===================================================== */

/* ===== Main Container ===== */
.tool-wrapper[data-tool="tsv-to-pdf"] {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: #1e293b;
}

/* ===== Status Messages ===== */
.status-message {
    background: #f8fafc;
    border: 1px solid #e9edf2;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #1e293b;
    display: none;
}
.status-message.show { display: block; }
.status-message.success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}
.status-message.error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

/* ===== Upload Area ===== */
.upload-area {
    background: #f8fafc;
    border: 2px dashed #d1d9e6;
    border-radius: 1rem;
    padding: 2.5rem 1.5rem;
    text-align: center;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    cursor: pointer;
    margin-bottom: 1.5rem;
}
.upload-area:hover {
    border-color: #0067b8;
    background: #f1f5f9;
}
.upload-area.drag-over {
    border-color: #0067b8;
    background: #e6f0fa;
    box-shadow: 0 0 0 4px rgba(0, 103, 184, 0.15);
}
.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.upload-icon {
    font-size: 3rem;
    color: #0067b8;
    margin-bottom: 0.25rem;
}
.upload-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: #0f172a;
}
.upload-hint {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0.1rem 0 0.5rem;
}
.upload-btn {
    background: #0067b8;
    color: #fff;
    border: none;
    padding: 0.6rem 2rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.upload-btn:hover {
    background: #005499;
    box-shadow: 0 4px 12px rgba(0, 103, 184, 0.25);
}
.upload-btn:active { transform: scale(0.97); }

/* ===== Processing Section ===== */
.processing-section {
    background: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    border: 1px solid #e9edf2;
    margin-top: 1.5rem;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}
@media (max-width: 768px) {
    .processing-section {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
}
.processing-section[style*="display: none"] { display: none !important; }

/* ===== File Info (Left Card) ===== */
.file-info {
    background: #f8fafc;
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid #e9edf2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 160px;
}
.file-info i {
    font-size: 2.5rem;
    color: #22c55e;
    margin-bottom: 0.5rem;
}
.file-name-display {
    font-weight: 600;
    color: #0f172a;
    font-size: 0.95rem;
    word-break: break-all;
    margin-bottom: 0.25rem;
}
.file-stats {
    font-size: 0.85rem;
    color: #475569;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}
.file-stats span {
    background: #eef2f6;
    padding: 0.15rem 0.8rem;
    border-radius: 1rem;
    white-space: nowrap;
}

/* ===== Processing Content (Right Area) ===== */
.processing-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Preview Textarea ===== */
.preview-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d9e6;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
    min-height: 350px;
    line-height: 1.6;
}
.preview-textarea:focus {
    border-color: #0067b8;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 103, 184, 0.12);
}
.preview-textarea::placeholder {
    color: #94a3b8;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}
.btn {
    padding: 0.6rem 1.8rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}
.btn-primary {
    background: #0067b8;
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
    background: #005499;
    box-shadow: 0 4px 12px rgba(0, 103, 184, 0.25);
}
.btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border: 1px solid #d1d9e6;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-success {
    background: #0b7e3d;
    color: #ffffff;
}
.btn-success:hover:not(:disabled) {
    background: #096633;
    box-shadow: 0 4px 12px rgba(11, 126, 61, 0.25);
}

/* ===== PDF Preview Section ===== */
.pdf-preview-section {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid #e9edf2;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}
.pdf-preview-section[style*="display: none"] { display: none !important; }

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.preview-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.preview-title i { color: #0067b8; }
.preview-actions {
    display: flex;
    gap: 0.5rem;
}
.btn-preview {
    padding: 0.4rem 1.2rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.85rem;
    background: #0067b8;
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-preview:hover {
    background: #005499;
    box-shadow: 0 4px 12px rgba(0, 103, 184, 0.25);
}

.pdf-viewer-container {
    background: #f8fafc;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid #e9edf2;
    min-height: 400px;
    position: relative;
}
.pdf-iframe {
    width: 100%;
    height: 600px;
    border: none;
    background: #fff;
}
.pdf-fallback {
    padding: 2rem;
    text-align: center;
    color: #475569;
    background: #f8fafc;
}
.pdf-fallback i {
    font-size: 1.5rem;
    color: #f59e0b;
    margin-right: 0.5rem;
}
.fallback-link {
    color: #0067b8;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}
.fallback-link:hover { color: #005499; }

/* ===== Progress Bar ===== */
.progress-container {
    background: #e9edf2;
    border-radius: 2rem;
    height: 24px;
    margin: 1rem 0 0.5rem 0;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}
.progress-bar-container {
    height: 100%;
    width: 100%;
    position: relative;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0067b8, #3b8fd9);
    border-radius: 2rem;
    transition: width 0.4s ease;
}
.progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.3px;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
}

/* ===== Success & Error Messages ===== */
.success-message {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    margin: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #065f46;
    font-weight: 500;
    font-size: 0.9rem;
}
.success-message i {
    color: #0b7e3d;
    font-size: 1.25rem;
}
.success-message[style*="display: none"] { display: none !important; }

.error-message {
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 0.5rem;
    padding: 0.75rem 1.25rem;
    margin: 0.75rem 0;
    color: #991b1b;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.error-message i {
    color: #dc2626;
    font-size: 1.1rem;
}
.error-message[style*="display: none"] { display: none !important; }

/* ===== Loading Indicator ===== */
.loading-indicator {
    display: none;
    text-align: center;
    padding: 2rem 0;
}
.loading-indicator[style*="display: block"] { display: block !important; }
.loading-spinner {
    font-size: 2.5rem;
    color: #0067b8;
    animation: spin 0.8s linear infinite;
}
.loading-text {
    margin-top: 0.5rem;
    font-weight: 500;
    color: #475569;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 768px) {
    .tool-wrapper[data-tool="tsv-to-pdf"] { padding: 0 0.5rem; margin: 1rem auto; }
    .processing-section { padding: 1rem; }
    .file-info { min-height: 120px; }
    .file-info i { font-size: 2rem; }
    .preview-textarea { min-height: 200px; }
    .pdf-iframe { height: 400px; }
    .action-buttons { flex-direction: column; align-items: stretch; }
    .action-buttons .btn { justify-content: center; width: 100%; }
    .preview-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .preview-actions { justify-content: center; }
}
@media (max-width: 480px) {
    .upload-area { padding: 1.5rem 1rem; }
    .upload-text { font-size: 1rem; }
    .upload-hint { font-size: 0.8rem; }
    .upload-btn { font-size: 0.85rem; padding: 0.4rem 1.2rem; }
    .pdf-iframe { height: 300px; }
    .preview-textarea { min-height: 150px; }
    .file-stats span { font-size: 0.75rem; padding: 0.1rem 0.5rem; }
}

/* ===== RTL Support ===== */
html[dir="rtl"] .btn i,
html[dir="rtl"] .upload-btn i,
html[dir="rtl"] .preview-title i,
html[dir="rtl"] .success-message i,
html[dir="rtl"] .file-info i {
    margin-left: 0.4rem;
    margin-right: 0;
}
html[dir="rtl"] .upload-area .upload-btn i {
    margin-left: 0.4rem;
    margin-right: 0;
}
html[dir="rtl"] .preview-textarea {
    direction: rtl;
    text-align: right;
}
html[dir="rtl"] .file-info {
    text-align: center;
}
html[dir="rtl"] .pdf-fallback i {
    margin-left: 0.5rem;
    margin-right: 0;
}
html[dir="rtl"] .error-message i {
    margin-left: 0.5rem;
    margin-right: 0;
}
html[dir="rtl"] .progress-text {
    left: auto;
    right: 0;
}