/* Custom styles for مدرک ساز (Document Generator) */

/* RTL Support and Persian Font */
body {
    font-family: 'Vazir', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    text-align: right;
    line-height: 1.6;
}

/* RTL specific adjustments */
.navbar-nav .nav-link {
    margin-left: 0;
    margin-right: 1rem;
}

.navbar-nav .nav-link:last-child {
    margin-right: 0;
}

.btn-group .btn:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

.btn-group .btn:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

/* RTL form controls */
.form-control, .form-select {
    text-align: right;
}

/* RTL table */
.table th, .table td {
    text-align: right;
}

/* RTL dropdown */
.dropdown-menu {
    text-align: right;
}

/* RTL modal */
.modal-header .btn-close {
    margin: -0.5rem auto -0.5rem -0.5rem;
}

/* RTL alert */
.alert-dismissible .btn-close {
    right: auto;
    left: 0;
}

/* Custom navbar styling */
.navbar-brand {
    font-weight: bold;
    font-size: 1.5rem;
}

/* Card enhancements */
.card {
    border-radius: 12px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    border-bottom: 1px solid #e9ecef;
}

/* Form styling */
.form-control, .form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Button styling */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a58ca 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Table styling */
.table {
    border-radius: 8px;
    overflow: hidden;
}

.table thead th {
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
    border: none;
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Excel table specific styling */
#excelTable input {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.875rem;
}

#excelTable input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.1rem rgba(13, 110, 253, 0.25);
}

/* Alert styling */
.alert {
    border-radius: 8px;
    border: none;
}

.alert-success {
    background: linear-gradient(135deg, #d1e7dd 0%, #badbcc 100%);
    color: #0f5132;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c2c7 100%);
    color: #842029;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #664d03;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

/* List group styling */
.list-group-item {
    border-radius: 8px !important;
    margin-bottom: 4px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease-in-out;
}

.list-group-item:hover {
    background-color: #f8f9fa;
    transform: translateX(-2px);
}

/* Modal styling */
.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 12px 12px;
}

/* Badge styling */
.badge {
    border-radius: 6px;
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Stack columns on mobile */
    .col-lg-8, .col-lg-4 {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    .drag-drop-zone {
        padding: 2rem 1rem;
        min-height: 120px;
    }
    
    .drag-drop-zone .drag-icon {
        font-size: 2.5rem;
    }
    
    .excel-table-container {
        font-size: 0.8rem;
    }
    
    .excel-table-container input {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Custom scrollbar */
.table-responsive::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Icon animations */
.fas, .fa {
    transition: transform 0.2s ease-in-out;
}

.btn:hover .fas,
.btn:hover .fa {
    transform: scale(1.1);
}

/* Template card specific styling */
.template-card {
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    border: 2px solid transparent;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    border-color: #0d6efd;
}

/* Drag and drop styling */
.drag-drop-zone {
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease-in-out;
    background-color: #f8f9fa;
    cursor: pointer;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.drag-drop-zone:hover {
    border-color: #0d6efd;
    background-color: #e7f3ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.15);
}

.drag-drop-zone.dragover {
    border-color: #0d6efd;
    background-color: #e7f3ff;
    transform: scale(1.02);
    box-shadow: 0 12px 30px rgba(13, 110, 253, 0.2);
}

.drag-drop-zone .drag-icon {
    font-size: 3.5rem;
    color: #6c757d;
    margin-bottom: 1rem;
    transition: all 0.3s ease-in-out;
}

.drag-drop-zone:hover .drag-icon {
    color: #0d6efd;
    transform: scale(1.1);
}

.drag-drop-zone.dragover .drag-icon {
    color: #0d6efd;
    transform: scale(1.2);
}

.drag-drop-zone p {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.drag-drop-zone .text-muted {
    font-size: 0.875rem;
}

/* Template grid styling */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
}

.template-item {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease-in-out;
    border: 1px solid #e9ecef;
}

.template-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    border-color: #0d6efd;
}

.template-item .template-icon {
    font-size: 2rem;
    color: #0d6efd;
    margin-bottom: 0.75rem;
    text-align: center;
}

.template-item .template-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: #212529;
    text-align: center;
}

.template-item .template-filename {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 1rem;
    text-align: center;
    word-break: break-all;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.template-actions .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 0.375rem 0.5rem;
}

/* Help section styling */
.help-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 2rem;
    margin-top: 3rem;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease-in-out;
}

.help-section.collapsed {
    max-height: 60px;
    overflow: hidden;
}

.help-section .help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 1rem;
}

.help-section .help-content {
    transition: all 0.3s ease-in-out;
}

.help-section.collapsed .help-content {
    opacity: 0;
    transform: translateY(-10px);
}

/* Excel table improvements */
.excel-table-container {
    max-width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.excel-table-container table {
    min-width: 800px;
}

.excel-table-container th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
    font-weight: 600;
    padding: 0.75rem;
    border: none;
}

.excel-table-container td {
    padding: 0.5rem;
    vertical-align: middle;
}

.excel-table-container input {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    width: 100%;
    transition: border-color 0.2s ease-in-out;
}

.excel-table-container input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.1rem rgba(13, 110, 253, 0.25);
    outline: none;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .template-actions {
        flex-direction: column;
    }
    
    .excel-table-container {
        font-size: 0.875rem;
    }
    
    .excel-table-container input {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}

/* File upload styling */
input[type="file"] {
    cursor: pointer;
}

input[type="file"]::-webkit-file-upload-button {
    background: #0d6efd;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
}

input[type="file"]::-webkit-file-upload-button:hover {
    background: #0b5ed7;
}

/* Success message animation */
@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert {
    animation: slideIn 0.3s ease-out;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Progress Circle Styling */
.progress-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(#0d6efd 0deg 0deg, #e9ecef 0deg 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
    transition: background 0.3s ease-in-out;
}

.progress-circle::before {
    content: '';
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: white;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-circle-inner {
    position: relative;
    z-index: 1;
    text-align: center;
}

.progress-circle-inner span {
    font-size: 1.5rem;
    font-weight: bold;
    color: #0d6efd;
    display: block;
}

/* Progress Modal Styling */
#progressModal .modal-content {
    border: none;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

#progressModal .modal-header {
    border-radius: 15px 15px 0 0;
    border-bottom: none;
    padding: 1.5rem;
}

#progressModal .modal-body {
    padding: 2rem;
}

#progressModal .modal-title {
    font-weight: 600;
    font-size: 1.1rem;
}

#progressTitle {
    color: #495057;
    font-weight: 600;
    font-size: 1.1rem;
}

#progressDescription {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Modal backdrop enhancement */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-backdrop.show {
    opacity: 0.8;
}
