/* ============================================================
   assets/css/template_form.css
   ============================================================ */

/* صفحة عرض القوالب */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.template-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}
.template-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0; left: 0; height: 4px;
    background: var(--card-color, #2563eb);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.4s;
}
.template-card:hover::before { transform: scaleX(1); }
.template-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    border-color: transparent;
}
.template-card .t-icon {
    width: 56px; height: 56px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff;
    background: var(--card-color, #2563eb);
    margin-bottom: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}
.template-card h5 {
    font-weight: 800; font-size: 1.1rem;
    color: #0f172a; margin-bottom: 6px;
}
.template-card p {
    color: #64748b; font-size: 0.88rem;
    line-height: 1.6; flex-grow: 1; margin-bottom: 14px;
}
.template-card .t-stats {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; color: #64748b;
    margin-bottom: 12px;
}
.template-card .btn-use {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; padding: 11px 20px;
    border-radius: 10px; font-weight: 700;
    font-size: 0.9rem; color: #fff;
    text-decoration: none; border: none; cursor: pointer;
    background: var(--card-color, #2563eb);
    transition: all 0.2s;
}
.template-card .btn-use:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    color: #fff;
}

/* النموذج */
.tf-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin: 20px 0;
}
@media (max-width: 992px) {
    .tf-layout { grid-template-columns: 1fr; }
}

.tf-form-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
}
.tf-form-card h5 {
    font-weight: 800; margin-bottom: 20px;
    color: #0f172a; display: flex;
    align-items: center; gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.tf-field {
    margin-bottom: 16px;
}
.tf-field label {
    display: block; font-weight: 700;
    font-size: 0.85rem; color: #1f2937;
    margin-bottom: 6px;
}
.tf-field label .req { color: #dc2626; }
.tf-field input,
.tf-field select,
.tf-field textarea {
    width: 100%; padding: 10px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
}
.tf-field input:focus,
.tf-field select:focus,
.tf-field textarea:focus {
    outline: none; background: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* صف التاريخ الهجري */
.hijri-row {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 8px;
}
.hijri-row select {
    padding: 10px 8px;
    text-align: center;
}

/* الفقاعة المساعدة */
.help-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: help;
    margin-right: 6px;
    position: relative;
}
.help-bubble:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 130%;
    right: 0;
    background: #1e293b;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: pre-wrap;
    width: 240px;
    line-height: 1.6;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* محرر المحتوى */
.tf-body-editor {
    width: 100%;
    min-height: 200px;
    padding: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 0.95rem;
    line-height: 1.8;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
}
.tf-body-editor:focus {
    outline: none; background: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* المعاينة */
.tf-preview-card {
    background: #f8fafc;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    position: sticky;
    top: 20px;
}
.tf-preview-card h5 {
    font-weight: 800; margin-bottom: 16px;
    color: #0f172a; display: flex;
    align-items: center; gap: 8px;
}

.preview-paper {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 30px 24px;
    min-height: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    font-family: 'Traditional Arabic', 'Sakkal Majalla', Tajawal, serif;
    font-size: 1rem;
    line-height: 2;
    color: #1e293b;
    direction: rtl;
}
.preview-paper .pp-header {
    text-align: center;
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #cbd5e1;
}
.preview-paper .pp-date {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 20px;
    color: #475569;
}
.preview-paper .pp-school {
    font-weight: 700;
    text-align: center;
    margin-bottom: 16px;
    color: #0f172a;
}
.preview-paper .pp-recipient {
    font-weight: 700;
    margin-bottom: 16px;
    color: #0f172a;
}
.preview-paper .pp-body {
    text-indent: 30px;
    margin: 20px 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.preview-paper .pp-closing {
    text-align: center;
    margin: 20px 0;
}
.preview-paper .pp-manager {
    margin-top: 30px;
    text-align: left;
    font-weight: 700;
}
.preview-paper .pp-footer {
    margin-top: 40px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* الأزرار */
.tf-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.tf-actions .btn-export {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 14px 24px;
    border-radius: 12px; font-weight: 800;
    font-size: 1rem; color: #fff;
    background: linear-gradient(135deg, #059669, #10b981);
    border: none; cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(5,150,105,0.25);
}
.tf-actions .btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(5,150,105,0.35);
    color: #fff;
}
.tf-actions .btn-export:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none;
}
.tf-actions .btn-reset {
    padding: 14px 20px;
    border-radius: 12px; font-weight: 700;
    color: #64748b; background: #f1f5f9;
    border: 2px solid #e2e8f0; cursor: pointer;
    transition: all 0.2s;
}
.tf-actions .btn-reset:hover {
    background: #fee2e2; color: #991b1b;
    border-color: #fecaca;
}

/* التنبيهات */
.tf-alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.tf-alert.success { background: #d1fae5; color: #065f46; }
.tf-alert.error   { background: #fee2e2; color: #991b1b; }
.tf-alert.warning { background: #fef3c7; color: #92400e; }
.tf-alert.info    { background: #dbeafe; color: #1e40af; }

/* Responsive */
@media (max-width: 576px) {
    .preview-paper { padding: 20px 16px; font-size: 0.9rem; }
    .tf-actions { flex-direction: column; }
    .hijri-row { grid-template-columns: 1fr; }
}