/* ==========================================================================
   Global App Layout Styles (from layouts/app.blade.php)
   ========================================================================== */
body {
    font-family: Vazirmatn, sans-serif !important;
    background-color: #f8fafc;
    color: #1e293b;
}

/* Datepicker Dark Mode Styles */
.dark jdp-container {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15) !important;
}
.dark jdp-container .jdp-icon-minus, 
.dark jdp-container .jdp-icon-plus {
    border-color: #334155 !important;
    background-color: #334155 !important;
}
.dark jdp-container .jdp-icon-minus svg, 
.dark jdp-container .jdp-icon-plus svg {
    fill: #f1f5f9 !important;
}
.dark jdp-container .jdp-months, 
.dark jdp-container .jdp-years {
    fill: #f1f5f9 !important;
    color: #f1f5f9 !important;
}
.dark jdp-container .jdp-month,
.dark jdp-container .jdp-month input,
.dark jdp-container .jdp-month select,
.dark jdp-container .jdp-time,
.dark jdp-container .jdp-time input,
.dark jdp-container .jdp-time select,
.dark jdp-container .jdp-year,
.dark jdp-container .jdp-year input,
.dark jdp-container .jdp-year select {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}
.dark jdp-container .jdp-day,
.dark jdp-container .jdp-day-name {
    color: #f1f5f9 !important;
}
.dark jdp-container .jdp-day-name {
    background-color: rgba(255, 255, 255, 0.05) !important;
}
.dark jdp-container .jdp-day:not(.disabled-day):hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
}
.dark jdp-container .jdp-day.today {
    border-color: #475569 !important;
}
.dark jdp-container .jdp-day.selected {
    background-color: #4f46e5 !important;
    color: #ffffff !important;
}
.dark jdp-container .jdp-btn-close,
.dark jdp-container .jdp-btn-empty,
.dark jdp-container .jdp-btn-today {
    background-color: #4f46e5 !important;
    color: #ffffff !important;
}
.dark jdp-container .jdp-btn-close:hover,
.dark jdp-container .jdp-btn-empty:hover,
.dark jdp-container .jdp-btn-today:hover {
    background-color: #4338ca !important;
}

/* استایل ناویگیشن */
.nav-link-active {
    color: #4f46e5;
    font-weight: 900;
    position: relative;
}

.nav-link-active::after {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 0;
    right: 0;
    height: 3.5px;
    background: #4f46e5;
    border-radius: 50px;
}

.glass-card {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 1.5rem;
    border: 1px solid rgba(231, 235, 241, 1);
    box-shadow: 0 25px 50px -12px rgba(79, 70, 229, 0.08);
}

/* --- سیستم فرم‌های پرمیوم (جهانی) --- */
.form-select-premium,
.form-input-premium {
    width: 100%;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.form-select-premium {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236366f1' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 1rem center;
    background-size: 1.1em;
    padding-left: 2.75rem !important;
}

.form-select-premium:focus,
.form-input-premium:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background-color: #fff;
    transform: translateY(-1px);
}

/* استایل دکمه‌های اصلی */
.btn-primary-premium {
    background-color: #4f46e5;
    color: white;
    font-weight: 900;
    padding: 0.875rem 1.5rem;
    border-radius: 1rem;
    transition: all 0.3s;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.2);
}

/* استایل کادر بازشونده سفارشی */
.custom-select-box {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 1.25rem;
    border: 1px solid rgba(231, 235, 241, 1);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.1);
    margin-top: 0.5rem;
    overflow: hidden;
    z-index: 100;
}

.custom-select-item {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    transition: all 0.2s;
    cursor: pointer;
    text-align: right;
}

.custom-select-item:hover {
    background-color: #f5f7ff;
    color: #4f46e5;
}

.form-trigger-premium {
    width: 100%;
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s;
    outline: none;
}

.form-trigger-premium:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* ==========================================================================
   Visits Show Page Styles (from admin/visits/show.blade.php)
   ========================================================================== */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}
@layer base {
    input:focus {
        outline: none !important;
        --tw-ring-color: transparent !important;
    }
}
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}

/* ==========================================================================
   Logs Page Styles (from admin/users/logs.blade.php)
   ========================================================================== */
.custom-pagination nav svg {
    width: 1.25rem;
    height: 1.25rem;
}

.custom-pagination nav p {
    font-weight: 900;
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 1rem;
    text-align: center;
}

.custom-pagination span,
.custom-pagination a {
    border-radius: 0.75rem !important;
    font-weight: 900 !important;
    font-family: 'Vazirmatn', sans-serif;
}

/* استایل مخصوص حالت تاریک برای پاراگراف در Pagination */
@media (prefers-color-scheme: dark) {
    .dark .custom-pagination nav p {
        color: #94a3b8;
    }
}

/* ==========================================================================
   Font Overrides (from welcome.blade.php & layouts/guest.blade.php)
   ========================================================================== */
body, font, span, div, p, h1, h2, h3, h4, h5, h6, a, input, button, select, textarea {
    font-family: Vazirmatn, sans-serif !important;
}

/* ==========================================================================
   Letters Index Styles (from admin/letters/index.blade.php)
   ========================================================================== */
#icon {
    font-size: 37px;
    padding-top: 10px;
}

/* ==========================================================================
   Timeline Styles (from admin/patients/timeline.blade.php)
   ========================================================================== */
@keyframes border-flash {
    0%, 100% {
        border-color: #e2e8f0;
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    }
}

.dark .flash-highlight {
    animation-name: border-flash-dark;
}

@keyframes border-flash-dark {
    0%, 100% {
        border-color: #334155;
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
    50% {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
    }
}

.flash-highlight {
    animation: border-flash 0.8s ease-in-out 3;
}

/* ==========================================================================
   Letter Verification Styles (from admin/letters/verify.blade.php)
   ========================================================================== */
@font-face {
    font-family: 'Vazirmatn';
    src: url('/melli/fonts/Vazir.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'MixedFont';
    src: local('Times New Roman');
    unicode-range: U+0000-007F;
}

@font-face {
    font-family: 'MixedFont';
    src: url('/melli/fonts/Vazir.woff2') format('woff2');
    unicode-range: U+0600-06FF;
}

.alert-box {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 15px 20px;
    margin: 20px auto;
    border-radius: 8px;
    max-width: 90%;
    width: 750px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    line-height: 1.6;
    box-sizing: border-box;
}

.alert-box strong {
    color: #d32f2f;
    font-size: 16px;
}

.paper-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 40px;
}

.paper {
    width: 198mm;
    height: 144mm;
    background-color: white;
    background-image: url('/letter/letter-head.jpg');
    position: relative;
    margin: 20px auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    overflow: hidden;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .paper {
        margin: 20px 10px;
    }
}

.element-number {
    position: absolute;
    left: 20mm;
    top: 3mm;
    font-size: 12px;
    color: #000;
}

.element-qr {
    position: absolute;
    left: 60mm;
    top: 3mm;
    width: 15mm;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.element-qr .qr-image {
    width: 15mm;
    height: 15mm;
}

.element-qr .qr-image svg {
    width: 15mm !important;
    height: 15mm !important;
}

.element-qr .auth-code {
    margin-top: 1mm;
    font-size: 8px;
    color: #000;
    white-space: nowrap;
}

.box-info {
    position: absolute;
    width: 35mm;
    height: 5mm;
    left: 15mm;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    overflow: hidden;
}

.element-date {
    bottom: 32mm;
    font-size: 12px;
}

.element-national-id {
    bottom: 44mm;
    font-size: 12px;
}

.element-patient {
    bottom: 56mm;
    text-align: center;
}

.element-content {
    position: absolute;
    left: 65mm;
    top: 20mm;
    right: 15mm;
    bottom: 15mm;
    color: #000;
    text-align: justify;
    line-height: 1.8;
    overflow: hidden;
}

/* ==========================================================================
   Letter Writer Styles (from admin/letters/writer.blade.php)
   ========================================================================== */
#drag-signature,
.qr-code-box,
.header-box {
    z-index: 20 !important;
}

#print-content-area-dynamic {
    z-index: 10 !important;
    position: relative;
    margin: 20px auto 0;
    min-height: 200px;
    padding: 25px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    line-height: 1.8;
    font-size: 12pt;
    text-align: justify;
    word-wrap: break-word;
    color: black;
    font-family: 'Vazirmatn', sans-serif !important;
    touch-action: none;
    user-select: none;
    width: 500px;
    font-size: 14px;
}

.draggable,
.is-resizable {
    touch-action: none;
    user-select: none;
}

.is-resizable {
    resize: both;
    overflow: hidden;
}

.is-resizable:hover {
    outline: 1px dashed #6366f1;
    background-color: rgba(99, 102, 241, 0.05);
}

.ui-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    background: #4f46e5;
    color: white;
    font-size: 10px;
    border-radius: 2px;
    cursor: move;
    width: 16px;
    height: 16px;
    z-index: 50;
}

.drag-handle-auto,
.resize-handle {
    direction: ltr !important;
    text-indent: 0 !important;
    text-align: center !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.drag-handle-auto {
    position: absolute;
    top: -12px;
    right: -12px;
    background-color: #4f46e5;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: move;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 50;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.drag-handle-auto:hover {
    transform: scale(1.1);
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border: 2px solid #4f46e5;
    border-radius: 50%;
    z-index: 50;
    opacity: 0;
    transition: opacity 0.2s;
}

.resize-tl {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-tr {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-bl {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-br {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

.main-resize-handle {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    background: rgba(79, 70, 229, 0.1);
    cursor: col-resize;
}

.main-resize-left {
    left: 0;
    border-left: 2px solid #4f46e5;
}

.main-resize-right {
    right: 0;
    border-right: 2px solid #4f46e5;
}

.draggable:hover .drag-handle-auto,
.is-resizable:hover .resize-handle,
.draggable:focus-within .drag-handle-auto {
    opacity: 1;
}

.toolbar-btn {
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
}

.toolbar-btn:hover {
    background-color: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
}

.toolbar-btn svg {
    width: 20px;
    height: 20px;
}

.flex.items-center.space-x-1>*+* {
    margin-right: 0.25rem;
    margin-left: 0;
}

.no-print button:active {
    transform: scale(0.95);
    background-color: #e0e7ff;
}

.no-print select {
    outline: none !important;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.5rem center;
    background-size: 0.8em;
    padding-left: 1.5rem !important;
}

#print-content-area-dynamic::-webkit-scrollbar {
    width: 4px;
}

#print-content-area-dynamic::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

#print-content-area-dynamic::selection {
    background-color: #c7d2fe;
    color: #312e81;
}

#print-content-area-dynamic:focus {
    background-color: rgba(249, 250, 251, 0.5);
}

#final-letter-text {
    font-family: 'Vazirmatn', sans-serif !important;
    direction: ltr;
    unicode-bidi: plaintext;
}

@font-face {
    font-family: 'EnglishTimes';
    src: local('Times New Roman');
    unicode-range: U+0020-007F, U+00A0-00FF;
}

@font-face {
    font-family: 'Vazir';
    src: url('/letter/fonts/Vazir.woff') format('woff');
    font-display: swap;
}

#paper-preview {
    width: 198mm;
    height: 143mm;
    background-color: white;
    background-image: url('/letter/letter-head.jpg');
    background-size: 100% 100%;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

@media print {
    @page {
        size: landscape;
        margin: 0;
    }

    body {
        visibility: hidden;
        background-color: white;
    }

    .no-print,
    .ui-handle {
        display: none !important;
    }

    #print-modal {
        position: absolute;
        left: 0;
        top: 0;
        margin: 0;
        padding: 0 !important;
        background: transparent !important;
        visibility: visible;
        display: block !important;
    }

    #paper-preview {
        visibility: visible;
        position: absolute;
        left: 12mm !important;
        top: 0;
        margin: 0 !important;
        box-shadow: none !important;
        width: 198mm !important;
        height: 144mm !important;
        page-break-after: avoid;
    }

    #paper-preview * {
        visibility: visible;
    }

    #paper-preview img {
        background-color: transparent !important;
        mix-blend-mode: multiply !important;
        box-shadow: none !important;
        filter: none !important;
    }

    .draggable,
    .is-resizable,
    #print-content-area-dynamic {
        border: none !important;
        background: transparent !important;
        outline: none !important;
        resize: none !important;
        box-shadow: none !important;
    }

    .hover\:border-indigo-500:hover,
    .hover\:bg-indigo-50\/50:hover {
        border-color: transparent !important;
        background-color: transparent !important;
    }
}
