/* Waqf Precision Aligner - Custom Styles */

/* Base Typography */
* {
    font-family: 'Cairo', sans-serif;
}

body {
    direction: rtl;
}

/* Arabic Quranic Text */
.ayah-text {
    font-family: 'Amiri', serif;
    font-size: 2.5rem;
    line-height: 2.8;
    text-align: center;
    direction: rtl;
    font-weight: 400;
}

/* Word States */
.word-candidate {
    background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.word-candidate:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    border-color: #d97706;
}

.word-aligned {
    /* ❌ REMOVED hardcoded green - colors now come from inline styles via getWordStyle() */
    /* background: linear-gradient(120deg, #6ee7b7 0%, #34d399 100%); */
    font-weight: 700;
    border-radius: 8px;
    padding: 6px 12px;
    /* box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3); */
}

.word-selected {
    background: linear-gradient(120deg, #c084fc 0%, #a855f7 100%);
    color: white;
    font-weight: 700;
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 3px 10px rgba(168, 85, 247, 0.5);
    animation: pulse 1s infinite;
}

.word-pending {
    background: linear-gradient(120deg, #fb923c 0%, #f97316 100%);
    color: white;
    font-weight: 700;
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.6);
    animation: bounce 0.8s infinite;
    border: 3px solid #ea580c;
}

.word-fragment {
    background: linear-gradient(120deg, #93c5fd 0%, #60a5fa 100%);
    border: 2px solid #3b82f6;
    color: white;
    font-weight: 600;
    border-radius: 8px;
    padding: 6px 12px;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

/* AI Fragment Selection Styles */
.word-ai-selected {
    background: rgba(168, 85, 247, 0.4);
    border: 2px solid #a855f7;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: bold;
    color: #1f2937;
}

.word-ai-edge {
    background: rgba(168, 85, 247, 0.6);
    border: 3px solid #7c3aed;
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: bold;
    color: #1f2937;
}

.word-normal {
    padding: 6px 12px;
    transition: all 0.2s ease;
    opacity: 0.6;
    cursor: default;
    color: #9ca3af;
}

/* Ayah Number Markers - Non-interactive */
.word-ayah-number {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1) !important;
    font-size: 0.9em;
    padding: 2px 8px;
    user-select: none;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    border-radius: 4px;
    box-shadow: none !important;
    font-weight: 600;
}

/* Words become clickable when an AI region is selected */
.word-ai-clickable {
    padding: 6px 12px;
    transition: all 0.2s ease;
    opacity: 1;
    cursor: pointer;
    color: #374151;
    border-radius: 6px;
    border: 1px dashed transparent;
}

.word-ai-clickable:hover {
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed rgba(59, 130, 246, 0.4);
    transform: scale(1.05);
}

.word-repeated {
    border: 2px dashed #a855f7 !important;
    background-color: rgba(168, 85, 247, 0.05);
    position: relative;
}

.word-extra {
    border: 2px dashed #6366f1 !important;
    background-color: rgba(99, 102, 241, 0.05);
    position: relative;
}

/* 🎨 Start Word Highlighting - Smooth Emerald Glow */
.word-start-marking {
    background: linear-gradient(135deg, #dcfce7 0%, #b9fbc0 100%) !important;
    border: 3px solid #10b981 !important;
    color: #065f46 !important;
    font-weight: 800 !important;
    transform: scale(1.1) rotate(1deg);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    position: relative;
    z-index: 20;
    animation: glow-emerald 1.5s infinite alternate;
}

.word-start-marking::before {
    content: '▶ البداية';
    position: absolute;
    top: -24px;
    right: 50%;
    transform: translateX(50%);
    font-size: 10px;
    background: #10b981;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 🎨 End Word Highlighting - Smooth Crimson Glow */
.word-end-marking {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%) !important;
    border: 3px solid #ef4444 !important;
    color: #991b1b !important;
    font-weight: 800 !important;
    transform: scale(1.1) rotate(-1deg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    position: relative;
    z-index: 20;
    animation: glow-crimson 1.5s infinite alternate;
}

.word-end-marking::before {
    content: '⏹ النهاية';
    position: absolute;
    top: -24px;
    right: 50%;
    transform: translateX(50%);
    font-size: 10px;
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

@keyframes glow-emerald {
    from {
        box-shadow: 0 0 5px rgba(16, 185, 129, 0.2);
    }

    to {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.6);
    }
}

@keyframes glow-crimson {
    from {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.2);
    }

    to {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
    }
}

.word-repeated::after {
    content: '🔁';
    position: absolute;
    top: -10px;
    right: -6px;
    font-size: 10px;
    background: white;
    border: 1px solid #d8b4fe;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.word-phase2 {
    background: transparent;
    border: none;
    color: #374151;
    padding: 2px 4px;
    cursor: text;
    transition: all 0.2s ease;
    user-select: text;
    display: inline;
}

.word-phase2:hover {
    background: rgba(229, 231, 235, 0.5);
}

/* Make text selection smooth and natural */
.ayah-text-container {
    cursor: text !important;
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    line-height: 2.2 !important;
}

.ayah-text-container * {
    cursor: text !important;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.ayah-text-container::selection {
    background: rgba(59, 130, 246, 0.4);
    color: inherit;
}

.ayah-text-container *::selection {
    background: rgba(59, 130, 246, 0.4);
    color: inherit;
}

/* Smooth highlight for selected fragment */
.word-ai-colored {
    display: inline;
    line-height: inherit;
    transition: all 0.2s ease;
}

/* Animation for text selection hint */
@keyframes selectHint {

    0%,
    100% {
        border-color: rgba(147, 51, 234, 0.3);
    }

    50% {
        border-color: rgba(147, 51, 234, 0.8);
        box-shadow: 0 0 20px rgba(147, 51, 234, 0.3);
    }
}

.select-text-hint {
    animation: selectHint 2s infinite;
}

.ayah-full-text {
    font-family: 'Amiri', serif;
    font-size: 2.5rem;
    line-height: 2.8;
    text-align: center;
    direction: rtl;
    font-weight: 400;
    cursor: text;
    user-select: text;
    padding: 20px;
    border-radius: 8px;
    background: #fafafa;
    border: 2px dashed #e5e7eb;
}

.ayah-full-text:hover {
    border-color: #9ca3af;
}

.word-span {
    display: inline;
    padding: 2px;
    border-radius: 3px;
    transition: all 0.3s ease;
    cursor: inherit;
}

.word-span:hover {
    background-color: rgba(147, 197, 253, 0.3);
}

/* Phase 2 text container styles */
.ayah-text-container {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

.ayah-text-container::selection {
    background-color: rgba(168, 85, 247, 0.4);
    color: inherit;
}

.ayah-text-container::-moz-selection {
    background-color: rgba(168, 85, 247, 0.4);
    color: inherit;
}

.word-normal:hover {
    opacity: 0.7;
    /* No background change on hover - not clickable */
}

/* Phase 2 click-based word selection styles */
.ayah-text-container {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.word-clickable {
    cursor: pointer;
    display: inline-block;
    padding: 4px 8px;
    margin: 2px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.word-clickable:hover {
    background-color: rgba(147, 197, 253, 0.3);
    transform: scale(1.05);
}

.word-clickable:active {
    transform: scale(0.98);
}

/* Enhanced word highlighting for Phase 2 */
.word-span:hover {
    background-color: rgba(147, 197, 253, 0.2);
    border-radius: 4px;
}

/* Pulse Animation for Selected Word */
@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Bounce Animation for Pending Word */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(-4px) scale(1.08);
    }
}

/* AI Region Highlight Pulse Animation */
@keyframes aiRegionPulse {

    0%,
    100% {
        opacity: 0.4;
        border-width: 3px;
    }

    50% {
        opacity: 0.7;
        border-width: 5px;
    }
}

.ai-region-highlight {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(147, 51, 234, 0.4);
    border: 3px solid #9333ea;
    pointer-events: none;
    animation: aiRegionPulse 1.5s infinite;
    z-index: 5;
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    padding: 14px 36px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.4);
    background: linear-gradient(135deg, #047857 0%, #059669 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary Button */
.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #9ca3af 100%);
    color: white;
    padding: 14px 36px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(107, 114, 128, 0.4);
    background: linear-gradient(135deg, #4b5563 0%, #6b7280 100%);
}

/* Danger Button */
.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    padding: 14px 36px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

.btn-disabled {
    background: #9ca3af !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.6;
}

/* RTL-specific adjustments */
[dir="rtl"] .container {
    text-align: right;
}

[dir="rtl"] .text-center {
    text-align: center !important;
}

/* Custom Wider Container for modern screens */
.container {
    max-width: 1400px !important;
}

/* WaveSurfer custom styling */
#waveform {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: linear-gradient(180deg, #f3f4f6 0%, #e5e7eb 100%);
    min-height: 150px;
}

/* Region Styles (for WaveSurfer) */
.wavesurfer-region {
    cursor: inherit;
    /* Inherit cursor from parent (crosshair during selection, pointer otherwise) */
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(16, 185, 129, 0.1);
    border-top: 4px solid #10b981;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Gradient Backgrounds */
.gradient-emerald {
    background: linear-gradient(135deg, #059669 0%, #10b981 50%, #34d399 100%);
}

.gradient-purple {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #c084fc 100%);
}

/* Arabic Number Styling */
.arabic-number {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
}

/* Phase Indicator */
.phase-indicator {
    position: relative;
    overflow: hidden;
}

.phase-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltip-text {
    visibility: hidden;
    background-color: #1f2937;
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    font-size: 0.875rem;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Responsive Typography */
@media (max-width: 768px) {
    .ayah-text {
        font-size: 2rem;
        line-height: 2.4;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Scrollbar Styling (for modern browsers) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 10px;
}

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

/* Focus States for Accessibility */
button:focus,
.cursor-pointer:focus {
    outline: 3px solid #10b981;
    outline-offset: 2px;
}

/* Success Message */
.success-message {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: slideIn 0.5s ease;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Error Message */
.error-message {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    animation: slideIn 0.5s ease;
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Modal Overlay (if needed) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   Beautiful Arabic Notification System
   ============================================ */

.notification-container {
    position: fixed;
    top: 80px;
    left: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
    direction: rtl;
}

.notification {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-right: 4px solid;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    pointer-events: auto;
    min-width: 320px;
    max-width: 420px;
    animation: slideInRight 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: all 0.3s ease;
}

.notification:hover {
    transform: translateX(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.notification-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

.notification-content {
    flex: 1;
    padding-top: 2px;
}

.notification-message {
    color: #1f2937;
    font-weight: 500;
    white-space: pre-line;
    word-wrap: break-word;
}

.notification-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    transition: all 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #111827;
}

/* Success Notification */
.notification-success {
    border-right-color: #10b981;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.notification-success .notification-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Error Notification */
.notification-error {
    border-right-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.notification-error .notification-icon {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

/* Warning Notification */
.notification-warning {
    border-right-color: #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.notification-warning .notification-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* Info Notification */
.notification-info {
    border-right-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.notification-info .notification-icon {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-enter {
    animation: slideInRight 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.notification-exit {
    animation: slideOutRight 0.3s ease;
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(-100px);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .notification-container {
        top: 60px;
        left: 10px;
        right: 10px;
        max-width: calc(100% - 20px);
    }

    .notification {
        min-width: auto;
        max-width: 100%;
        font-size: 14px;
        padding: 14px 16px;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake-animation {
    animation: shake 0.2s ease-in-out 0s 2;
}

.coverage-warning {
    box-shadow: 0 0 15px rgba(251, 146, 60, 0.4);
}

.shake-warning {
    animation: shake-hard 0.4s ease-in-out infinite;
}

@keyframes shake-hard {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-8px);
    }

    80% {
        transform: translateX(8px);
    }
}

.attention-glow {
    animation: attention-glow-anim 1.5s ease-in-out infinite;
    z-index: 50;
    position: relative;
}

@keyframes attention-glow-anim {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(239, 68, 68, 0.5), inset 0 0 5px rgba(239, 68, 68, 0.2);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.8), inset 0 0 10px rgba(239, 68, 68, 0.4);
        transform: scale(1.1);
        border-color: #ef4444;
    }
}

.ai-prediction-item.attention-glow {
    border: 3px solid #ef4444 !important;
}

 . s k i p - c h i p - t r a n s i t i o n    {
               t r a n s i t i o n :    a l l   0 . 2 s   c u b i c - b e z i e r ( 0 . 4 ,    0 ,    0 . 2 ,    1 ) ;
       
}

       