/* Modern Reusable ModalBox Styles - Premium UI Refinement */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    /* Dark muted overlay */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    /* Clean glassmorphism */
    transition: all 0.3s ease;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    background-color: #fff;
    width: 95%;
    max-width: 600px; /* New default: Medium */
    border-radius: 20px;
    /* Modern ultra-soft corners */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: max-width 0.3s ease;
}

/* Modal Sizing Modifiers */
.modal-box.modal-sm { max-width: 400px; }
.modal-box.modal-md { max-width: 600px; }
.modal-box.modal-lg { max-width: 900px; }
.modal-box.modal-xl { max-width: 1200px; }
.modal-box.modal-fullscreen {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
    animation: none;
}

.modal-box.modal-fullscreen #modalMainContent {
    height: calc(100vh - 85px);
    display: flex;
    flex-direction: column;
}

.modal-box.modal-fullscreen .modal-body {
    flex: 1;
    max-height: none;
}

@keyframes modalSlideUp {
    0% {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }

    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    background: #fff;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
}

.modal-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.02em;
}

/* Hazirun modal title composition */
.hazirun-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hazirun-title-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-gradient-end) 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-primary) 28%, transparent);
}

.hazirun-title-chip svg {
    opacity: 0.95;
}

.hazirun-modal-event-name {
    color: #334155;
    font-size: 0.95rem;
    font-weight: 600;
}

.modal-expand {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-expand:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.modal-close {
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-close:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg);
}

.modal-expand.hidden {
    display: none;
}

.modal-body {
    padding: 1.5rem;
    background-color: #fff;
    overflow-x: auto;
    position: relative;
    max-height: 600px;
}

.modal-content-header {
    color: var(--brand-primary);
    /* Brand Primary */
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.01em;
}

.modal-form-group {
    margin-bottom: 1.5rem;
}

.teslim-modal-form .modal-form-group:last-child {
    margin-bottom: 0;
}

.modal-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.6rem;
    color: #475569;
    font-size: 0.9rem;
}

.modal-select,
.modal-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #1e293b;
    transition: all 0.2s;
    outline: none;
    background-color: #f8fafc;
}

.modal-select:focus,
.modal-input:focus {
    border-color: var(--brand-primary);
    background-color: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}

.modal-footer {
    padding: 1.25rem 2rem;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-btn {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-gradient-end) 100%);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    width: auto;
}

.modal-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.modal-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.modal-btn:active {
    transform: translateY(0);
}

.modal-btn-secondary {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* Modern Tooltip Styles */
.custom-tooltip {
    position: fixed;
    background: #1e293b;
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    pointer-events: none;
    z-index: 3000;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.custom-tooltip.show {
    opacity: 1;
}

/* Dark Mode Modal Tuning */
[data-theme="dark"] .modal-box {
    background-color: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body {
    background-color: #1e293b;
}

[data-theme="dark"] .modal-title {
    color: #f8fafc;
}

[data-theme="dark"] .hazirun-modal-event-name {
    color: #cbd5e1;
}

[data-theme="dark"] .modal-expand,
[data-theme="dark"] .modal-close {
    background: #334155;
    color: #cbd5e1;
}

[data-theme="dark"] .modal-expand:hover {
    background: #475569;
    color: #f8fafc;
}

/* Modal Table Enhancements */
.modal-body.modal-body-flush {
    padding: 0; /* Remove padding only for table layout modals */
}

.hazirun-modal-layout {
    display: flex;
    height: 100%;
    min-height: 500px;
    max-height: 600px;
    overflow: hidden; /* Main container should not scroll */
}

/* Fullscreen modda sabit yükseklik sınırını kaldırıp alanı tamamen doldur */
.modal-box.modal-fullscreen .hazirun-modal-layout {
    min-height: 0;
    max-height: none;
    height: 100%;
}

.modal-box.modal-fullscreen .hazirun-table-side,
.modal-box.modal-fullscreen .hazirun-preview-side {
    height: 100%;
}

.hazirun-table-side {
    flex: 3;
    padding: 0; 
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    border-right: 1px solid #e2e8f0;
}

.hazirun-preview-side {
    flex: 1.2;
    padding: 0;
    background: #f8fafc;
    overflow-y: auto; /* Internal scroll for preview */
}

.preview-title {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f8fafc;
    font-size: 0.9rem;
    font-weight: 700;
    color: #475569;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space for count badge */
    border-bottom: 1px solid #e2e8f0;
}

.preview-count-badge {
    background: var(--brand-primary);
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 700;
}

.preview-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 1rem 1.5rem;
}

.preview-item {
    font-size: 0.85rem;
    color: #1e293b;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: fadeIn 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.preview-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: color-mix(in srgb, var(--brand-primary) 12%, transparent);
    color: var(--brand-primary);
    border-radius: 4px;
    font-weight: 600;
}

/* Custom scrollbar for premium look */
.hazirun-preview-side::-webkit-scrollbar {
    width: 6px;
}
.hazirun-preview-side::-webkit-scrollbar-track {
    background: transparent;
}
.hazirun-preview-side::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}
.hazirun-preview-side::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.preview-remove-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.preview-remove-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.modal-body .modern-table { border-collapse: separate; border-spacing: 0; width: 100%; }

.modal-body .modern-table thead th {
    position: sticky;
    top: 86px; 
    z-index: 90;
    background: #f8fafc !important;
    box-shadow: 0 2px 0 #e2e8f0;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    padding: 1rem 0.75rem; /* Reduced padding */
    white-space: nowrap;
    color: #475569;
    font-size: 0.85rem;
    text-align: left;
}

.modal-body .modern-table thead th:hover {
    background: #edf2f7 !important;
}

.sort-icon {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    opacity: 0.3;
    font-size: 0.8rem;
    vertical-align: middle;
}

.sort-active .sort-icon { opacity: 1; color: var(--brand-primary); }

.modal-body .modern-table td {
    padding: 0.75rem 0.75rem; /* Match header padding */
    font-size: 0.85rem;
}

/* Explicit column widths to ensure fit */
.h-tckn { width: 120px; }
.h-tip { width: 80px; }
.h-tel { width: 130px; }

.modal-body .modern-table th:first-child,
.modal-body .modern-table td:first-child {
    text-align: center;
    width: 50px;
    padding-left: 1rem;
    padding-right: 1rem;
}

.modal-body .modern-table tr.selected-row {
    background-color: color-mix(in srgb, var(--brand-primary) 9%, transparent) !important;
}

.modal-body .modern-table tr.selected-row td {
    color: var(--brand-primary);
    font-weight: 600;
}

.modal-search-wrapper {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
    padding: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    width: 100%;
    display: flex;
    align-items: center;
}

.search-input-container {
    position: relative;
    width: 100%; /* Take full width of wrapper */
    max-width: 600px; /* But don't go too crazy */
}

.search-input-container svg.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.modal-search-input {
    width: 100%;
    padding: 0.7rem 2.8rem 0.7rem 2.8rem; /* Enough room for left icon and right clear button */
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
    background: #f8fafc;
}

.modal-search-input:focus {
    background: #fff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}

.modal-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #e2e8f0;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    padding: 0;
    transition: all 0.2s;
}

.modal-search-clear:hover {
    background: #cbd5e1;
    color: #1e293b;
}

.modal-search-clear.show {
    display: flex;
}

@media (max-width: 992px) {
    .hazirun-modal-layout { flex-direction: column; }
    .hazirun-table-side { border-right: none; border-bottom: 1px solid #e2e8f0; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

[data-theme="dark"] .modal-footer {
    background-color: #0f172a;
    border-top-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .modal-label {
    color: #cbd5e1;
}

[data-theme="dark"] .modal-select,
[data-theme="dark"] .modal-input {
    background-color: #334155;
    border-color: #475569;
    color: #f8fafc;
}

/* Hazirun modal — dark theme (arama, tablo başlığı, seçilenler paneli, iptal) */
[data-theme="dark"] .modal-header {
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .modal-btn-secondary {
    background: var(--gray-50);
    border-color: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .modal-btn-secondary:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-800);
}

[data-theme="dark"] .hazirun-table-side {
    border-right-color: var(--gray-200);
}

@media (max-width: 992px) {
    [data-theme="dark"] .hazirun-table-side {
        border-bottom-color: var(--gray-200);
    }
}

[data-theme="dark"] .hazirun-preview-side {
    background: var(--gray-50);
}

[data-theme="dark"] .preview-title {
    background: var(--gray-50);
    color: var(--gray-700);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .preview-item {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-200);
    box-shadow: none;
}

[data-theme="dark"] .modal-search-wrapper {
    background: var(--gray-50);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .modal-search-input {
    background: var(--gray-50);
    border-color: var(--gray-200);
    color: var(--gray-800);
}

[data-theme="dark"] .modal-search-input::placeholder {
    color: var(--gray-500);
}

[data-theme="dark"] .modal-search-input:focus {
    background: var(--gray-100);
    border-color: var(--brand-primary);
}

[data-theme="dark"] .modal-search-clear {
    background: var(--gray-200);
    color: var(--gray-700);
}

[data-theme="dark"] .modal-search-clear:hover {
    background: var(--gray-300);
    color: var(--gray-900);
}

[data-theme="dark"] .search-input-container svg.search-icon {
    color: var(--gray-500);
}

[data-theme="dark"] .modal-body .modern-table thead th {
    background: var(--gray-200) !important;
    box-shadow: 0 2px 0 var(--gray-300);
    color: var(--gray-700);
}

[data-theme="dark"] .modal-body .modern-table thead th:hover {
    background: var(--gray-300) !important;
}

[data-theme="dark"] .modal-body .modern-table td {
    color: var(--gray-600);
    border-bottom-color: var(--gray-200);
}

[data-theme="dark"] .modal-body .modern-table tbody tr:hover td {
    background: color-mix(in srgb, var(--gray-100) 80%, transparent);
}

[data-theme="dark"] .hazirun-preview-side::-webkit-scrollbar-thumb {
    background: var(--gray-300);
}

[data-theme="dark"] .hazirun-preview-side::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

[data-theme="dark"] .preview-remove-btn:hover {
    background: color-mix(in srgb, var(--danger) 22%, transparent);
    color: var(--danger);
}

.hazirun-preview-empty {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-align: center;
    padding: 1rem;
}

[data-theme="dark"] .hazirun-preview-empty {
    color: var(--gray-400);
}

.hazirun-table-empty {
    text-align: center;
    padding: 2rem;
    color: var(--gray-600);
}

[data-theme="dark"] .hazirun-table-empty {
    color: var(--gray-400);
}

.modal-body .modern-table thead th.hazirun-th-checkbox {
    width: 40px;
    text-align: center;
}

/* Circle Checkbox System */
.circle-checkbox {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    -webkit-user-select: none;
    user-select: none;
}

.circle-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.circle-checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 22px;
    width: 22px;
    background-color: #f1f5f9;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.circle-checkbox:hover input ~ .circle-checkmark {
    border-color: var(--brand-primary);
    background-color: #fff;
    transform: scale(1.05);
}

.circle-checkbox input:checked ~ .circle-checkmark {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.circle-checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.circle-checkbox input:checked ~ .circle-checkmark:after {
    display: block;
}

/* Dark Mode support for Circle Checkbox */
[data-theme="dark"] .circle-checkmark {
    background-color: #334155;
    border-color: #475569;
}

[data-theme="dark"] .circle-checkbox:hover input ~ .circle-checkmark {
    background-color: var(--gray-100);
}

/* Dışa aktarım — kolon seçimi (daire checkbox + metin satırı) */
.export-col-section {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--gray-200);
}

[data-theme="dark"] .export-col-section {
    border-top-color: var(--gray-300);
}

.export-col-section__title {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 800;
}

[data-theme="dark"] .export-col-section__title {
    /* Dark mode'da --gray-200 koyu kaldığı için okunurluk düşüyordu */
    color: var(--gray-700);
}

.export-col-section__list {
    max-height: 240px;
    overflow: auto;
    padding-right: 0.25rem;
}

.export-col-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.export-col-row .circle-checkbox {
    flex-shrink: 0;
}

.export-col-row__text {
    font-size: 0.875rem;
    color: var(--gray-800);
    line-height: 1.35;
}

[data-theme="dark"] .export-col-row__text {
    /* Dark mode'da --gray-100 arka plan ile aynı tona geliyordu */
    color: var(--gray-800);
}

/* Excel export modal (loading + record count) */
.excel-export-modal {
    padding: 0.5rem 0.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.excel-export-spinner {
    width: 46px;
    height: 46px;
    border-radius: 9999px;
    border: 5px solid color-mix(in srgb, var(--brand-primary) 22%, transparent);
    border-top-color: var(--brand-primary);
    animation: excelExportSpin 0.85s linear infinite;
    box-sizing: border-box;
}

@keyframes excelExportSpin {
    to { transform: rotate(360deg); }
}

.excel-export-count {
    font-weight: 800;
    color: var(--gray-800);
    font-size: 1rem;
}

.excel-export-loading {
    color: var(--gray-600);
    font-weight: 600;
}

[data-theme="dark"] .excel-export-count {
    color: var(--gray-100);
}

[data-theme="dark"] .excel-export-loading {
    color: var(--gray-200);
}
