/* HamiAnalyzer Custom Styles */

:root {
    --primary-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navigation */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

.nav-link {
    transition: all 0.3s ease;
}

.nav-link:hover {
    transform: translateY(-2px);
}

/* Cards */
.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Buttons */
.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Statistics Cards */
.stat-card {
    border-left: 4px solid var(--primary-color);
}

.stat-card.success {
    border-left-color: var(--success-color);
}

.stat-card.danger {
    border-left-color: var(--danger-color);
}

.stat-card.warning {
    border-left-color: var(--warning-color);
}

.stat-card.info {
    border-left-color: var(--info-color);
}

/* Table Styles */
.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
    cursor: pointer;
}

/* Loading Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Plot Images */
.plot-thumbnail {
    transition: transform 0.3s ease;
    cursor: pointer;
}

.plot-thumbnail:hover {
    transform: scale(1.05);
}

/* Alert Animations */
.alert {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer */
footer {
    margin-top: auto;
    border-top: 1px solid #dee2e6;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .display-1 {
        font-size: 4rem;
    }
    
    .display-5 {
        font-size: 2rem;
    }
    
    .display-6 {
        font-size: 1.75rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Form Controls */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Progress Bar */
.progress {
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.6s ease;
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: 10px;
}

.modal-header {
    border-bottom: 2px solid #f8f9fa;
}

/* List Group */
.list-group-item {
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.list-group-item:hover {
    border-left-color: var(--primary-color);
    background-color: rgba(13, 110, 253, 0.05);
}

/* Badge Styles */
.badge {
    font-weight: 600;
    padding: 0.5em 0.75em;
}

/* Card Header Enhancements */
.card-header {
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* Image Zoom */
.img-fluid {
    max-width: 100%;
    height: auto;
}

/* Dropdown Menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

.dropdown-item {
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--primary-color);
    color: white;
    padding-left: 1.5rem;
}

/* Click to Copy Reference Code */
.ref-code-copy {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.ref-code-copy:hover {
    background-color: #e9ecef;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.ref-code-copy i {
    opacity: 0.5;
    margin-left: 4px;
}

.ref-code-copy:hover i {
    opacity: 1;
}

/* =========================================
   File Preview Modal Styles
   Optimized for Persian/RTL text and long content
   ========================================= */

/* Full-screen modal for better table viewing */
.modal-fullscreen .modal-content {
    border-radius: 0;
}

/* File preview table base styles */
.file-preview-table {
    font-size: 0.875rem;
    direction: ltr;
    table-layout: auto;
    width: 100%;
}

.file-preview-table th,
.file-preview-table td {
    vertical-align: middle;
    white-space: normal;
    word-wrap: break-word;
    padding: 0.75rem 1rem;
}

/* Sticky header for scrolling */
.file-preview-table thead.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
}

.file-preview-table thead th {
    background-color: #212529;
    color: #fff;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid #495057;
    white-space: nowrap;
}

/* Persian/RTL text support in cells */
.file-preview-table .cell-content {
    display: block;
    max-width: 400px;
    line-height: 1.6;
}

/* Auto-detect and apply RTL for Persian content */
.file-preview-table .cell-content.rtl-text {
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Tahoma', 'B Nazanin', sans-serif;
}

/* Message column - special handling for long text */
.file-preview-table .message-cell {
    max-width: 500px;
    min-width: 250px;
}

.file-preview-table .message-cell .cell-content {
    max-width: 500px;
    max-height: 150px;
    overflow-y: auto;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

/* Date column */
.file-preview-table .date-cell {
    white-space: nowrap;
    min-width: 140px;
    font-family: monospace;
    text-align: center;
}

/* ID/Code columns */
.file-preview-table .code-cell {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
    background-color: #f1f3f5;
    text-align: center;
}

/* Name column - often Persian */
.file-preview-table .name-cell {
    min-width: 150px;
}

/* Subject column */
.file-preview-table .subject-cell {
    min-width: 200px;
    max-width: 350px;
}

/* Reference code column */
.file-preview-table .reference-cell {
    font-family: monospace;
    font-size: 0.75rem;
    max-width: 180px;
    word-break: break-all;
}

/* Row number column */
.file-preview-table .row-number-cell {
    width: 50px;
    text-align: center;
    font-weight: 600;
    background-color: #e9ecef;
}

/* Hover effect */
.file-preview-table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.08) !important;
}

/* Alternating row colors */
.file-preview-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Empty cell indicator */
.file-preview-table .empty-cell {
    color: #adb5bd;
    font-style: italic;
}

/* Boolean/matched cell */
.file-preview-table .bool-cell.true {
    color: #198754;
    font-weight: 600;
}

.file-preview-table .bool-cell.false {
    color: #dc3545;
}

/* Modal footer pagination */
#preview-pagination {
    gap: 0.5rem;
}

#pagination-info {
    min-width: 120px;
    text-align: center;
}

/* Preview loading state */
#preview-loading {
    min-height: 300px;
}

/* Preview table container - makes table scrollable */
#preview-table-container {
    overflow-x: auto;
    overflow-y: auto;
}

/* Expandable cell for very long content */
.file-preview-table .expandable-cell {
    position: relative;
}

.file-preview-table .expand-btn {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 0.7rem;
    color: #0d6efd;
    cursor: pointer;
    background: none;
    border: 1px solid #0d6efd;
    border-radius: 4px;
}

.file-preview-table .expand-btn:hover {
    background-color: #0d6efd;
    color: white;
}

/* Column-specific widths for combined_output files */
.file-preview-table.combined-file .col-date { min-width: 160px; }
.file-preview-table.combined-file .col-message { min-width: 300px; max-width: 500px; }
.file-preview-table.combined-file .col-from { min-width: 150px; max-width: 250px; }
.file-preview-table.combined-file .col-to { min-width: 150px; max-width: 250px; }
.file-preview-table.combined-file .col-email { min-width: 200px; }
.file-preview-table.combined-file .col-id { min-width: 100px; }
.file-preview-table.combined-file .col-matched { width: 80px; }

/* Column-specific widths for hami_output files */
.file-preview-table.hami-file .col-number { width: 60px; }
.file-preview-table.hami-file .col-subject { min-width: 250px; max-width: 400px; }
.file-preview-table.hami-file .col-reference { min-width: 180px; }
.file-preview-table.hami-file .col-major { min-width: 200px; max-width: 350px; }
.file-preview-table.hami-file .col-name { min-width: 150px; max-width: 250px; }
.file-preview-table.hami-file .col-national-id { min-width: 120px; }
.file-preview-table.hami-file .col-student-id { min-width: 140px; }
.file-preview-table.hami-file .col-field { min-width: 200px; max-width: 350px; }

/* Responsive adjustments for smaller screens */
@media (max-width: 992px) {
    .file-preview-table {
        font-size: 0.8rem;
    }
    
    .file-preview-table th,
    .file-preview-table td {
        padding: 0.5rem;
    }
    
    .file-preview-table .cell-content {
        max-width: 250px;
    }
    
    .file-preview-table .message-cell .cell-content {
        max-width: 300px;
    }
}

/* Persian font support: Vazirmatn from this site's own files (no outside CDN) */
@font-face {
    font-family: 'Vazirmatn';
    src: url('../lib/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('../lib/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}


/* ========================================
   Graph View Styles
   ======================================== */

/* Graph container */
#graph-container {
    background-color: #fafafa;
    background-image: 
        radial-gradient(circle, #e0e0e0 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Graph info panel */
#graph-info-panel {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    border-right: 4px solid #4CAF50;
}

#graph-info-panel h6 {
    color: #4CAF50;
}

#graph-info-content {
    font-size: 0.9rem;
}

#graph-info-content .info-label {
    font-weight: 600;
    color: #666;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

#graph-info-content .info-value {
    color: #333;
    margin-bottom: 10px;
    word-break: break-word;
}

#graph-info-content .info-value.persian-text {
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

#graph-info-content .message-text {
    background-color: #f5f5f5;
    padding: 10px;
    border-radius: 6px;
    border-right: 3px solid #2196F3;
    direction: rtl;
    text-align: right;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

/* Graph statistics badge */
#graph-stats {
    font-size: 0.8rem;
}

/* Graph legend */
.graph-legend {
    font-size: 0.85rem;
}

/* Node selection highlight effect */
.node-selected {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

/* Edge tooltip styles */
.vis-tooltip {
    background-color: white !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    padding: 10px !important;
    font-family: 'Vazirmatn', 'Tahoma', sans-serif !important;
    direction: rtl !important;
    max-width: 300px !important;
}

/* Graph view button styles */
.btn-graph-view {
    background-color: #4CAF50;
    border-color: #4CAF50;
    color: white;
}

.btn-graph-view:hover {
    background-color: #388E3C;
    border-color: #388E3C;
    color: white;
}

.btn-graph-view:focus {
    box-shadow: 0 0 0 0.25rem rgba(76, 175, 80, 0.25);
}

/* Graph control buttons */
.graph-control-btn {
    transition: all 0.2s ease;
}

.graph-control-btn:hover {
    transform: scale(1.05);
}

/* Empty graph message */
.graph-empty-message {
    text-align: center;
    padding: 50px;
    color: #666;
}

.graph-empty-message i {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 20px;
}

/* Graph modal loading overlay */
#graph-loading {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
}

/* Search Progress Bar Styles */
#search-progress-container {
    animation: fadeIn 0.3s ease-out;
}

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

#search-progress-bar {
    background: linear-gradient(90deg, #0d6efd 0%, #0dcaf0 50%, #0d6efd 100%);
    background-size: 200% 100%;
    animation: progressGradient 2s ease infinite;
    transition: width 0.3s ease-out;
}

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

.search-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

#search-progress-container .progress {
    height: 24px;
    border-radius: 12px;
    background-color: #e9ecef;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

#search-progress-container .progress-bar {
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 24px;
}

/* Progress states */
#search-progress-bar.progress-complete {
    background: #198754;
    animation: none;
}

#search-progress-bar.progress-error {
    background: #dc3545;
    animation: none;
}

