/* ===== Template Detail Page ===== */

.tpl-detail-wrap {
    max-width: 1280px;
    width: 95%;
    margin: 0 auto;
    padding: 100px 24px 80px;
}

/* Header */
.tpl-detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.tpl-detail-header-icon {
    width: 48px;
    height: 48px;
    background: #f0f4ff;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tpl-detail-title {
    font-size: 24px;
    font-weight: 700;
    color: #12294B;
    margin: 0;
    line-height: 1.3;
}

/* Main layout */
.tpl-detail-body {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

/* Document preview */
.tpl-detail-preview {
    flex: 1;
    min-width: 0;
    max-width: 75%;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(18, 41, 75, 0.06);
    box-shadow: 0 2px 8px rgba(18, 41, 75, 0.04);
    padding: 24px;
    overflow: auto;
}

.tpl-detail-preview .template-text {
    max-width: 100%;
    border: none;
    padding: 0;
}

/* Zoom bar */
.tpl-zoom-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f2f7;
}

.tpl-zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #e0e6ee;
    background: #f8f9fb;
    color: #5a6a7e;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tpl-zoom-btn:hover {
    background: #e0e6ee;
    border-color: #c8cfd8;
    color: #12294B;
}

.tpl-zoom-value {
    font-size: 13px;
    font-weight: 600;
    color: #5a6a7e;
    min-width: 42px;
    text-align: center;
}

/* ===== Edit/Create Template Form ===== */
.tpl-edit-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tpl-edit-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tpl-edit-label {
    font-size: 13px;
    font-weight: 600;
    color: #5a6a7e;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.tpl-edit-hint {
    font-size: 12px;
    color: #9ba8b7;
    margin: 0;
}

.tpl-edit-form .input-field,
.tpl-edit-form input[type="text"],
.tpl-edit-form input[type="number"],
.tpl-edit-form textarea,
.tpl-edit-form select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e6ee;
    border-radius: 10px;
    font-size: 14px;
    color: #12294B;
    background: #f8f9fb;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.tpl-edit-form .input-field:focus,
.tpl-edit-form input[type="text"]:focus,
.tpl-edit-form textarea:focus,
.tpl-edit-form select:focus {
    border-color: var(--color-blue-dark, #3657CD);
    box-shadow: 0 0 0 3px rgba(54, 87, 205, 0.1);
    background: #ffffff;
}

.tpl-edit-form select[multiple] {
    min-height: 120px;
    padding: 8px;
}

.tpl-edit-checks {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tpl-edit-check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: #3a4a5e;
}

.tpl-edit-check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-blue-dark, #12294B);
    cursor: pointer;
    flex-shrink: 0;
}

/* CKEditor container */
.tpl-edit-form .django-ckeditor-widget {
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.tpl-detail-preview-images {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tpl-detail-preview-images img {
    max-width: 100%;
    border-radius: 8px;
}

/* Sidebar */
.tpl-detail-sidebar {
    width: 25%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Sidebar card */
.tpl-detail-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(18, 41, 75, 0.06);
    box-shadow: 0 2px 8px rgba(18, 41, 75, 0.04);
    padding: 24px;
}

.tpl-detail-card h2 {
    font-size: 15px;
    font-weight: 700;
    color: #12294B;
    margin: 0 0 16px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Variable blocks (radio/checkbox groups) */
.tpl-detail-var-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tpl-detail-var-option {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.tpl-detail-var-option input[type="radio"],
.tpl-detail-var-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-blue-dark, #12294B);
    cursor: pointer;
    flex-shrink: 0;
}

.tpl-detail-var-option label {
    font-size: 14px;
    color: #3a4a5e;
    cursor: pointer;
    line-height: 1.4;
    margin: 0;
}

/* Variable input fields */
.tpl-detail-card .var-field-div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tpl-detail-card .var-field-div label {
    font-size: 13px;
    font-weight: 600;
    color: #5a6a7e;
}

.tpl-detail-card .var-field,
.tpl-detail-card .form-control,
.tpl-detail-card .form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #e0e6ee;
    border-radius: 10px;
    font-size: 14px;
    color: #12294B;
    background: #f8f9fb;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tpl-detail-card .form-select,
.tpl-detail-card select.var-field {
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%235a6a7e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    cursor: pointer;
    outline: none;
}

.tpl-detail-card .var-field:focus,
.tpl-detail-card .form-control:focus,
.tpl-detail-card .form-select:focus {
    border-color: var(--color-blue-dark, #3657CD);
    box-shadow: 0 0 0 3px rgba(54, 87, 205, 0.1);
    background: #ffffff;
}

.tpl-detail-card .var-field.input-error {
    border-color: #d32f2f;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.tpl-detail-card textarea.var-field,
.tpl-detail-card textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* Edit form actions (horizontal) */
.tpl-edit-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.tpl-edit-actions .tpl-detail-btn {
    width: auto;
}


@media (max-width: 480px) {
    .tpl-edit-actions {
        flex-direction: column-reverse;
    }
    .tpl-edit-actions .tpl-detail-btn {
        width: 100%;
    }
}

/* Action buttons */
.tpl-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tpl-detail-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    text-decoration: none;
    text-align: center;
    line-height: 1.4;
}

.tpl-detail-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

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

.tpl-detail-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tpl-detail-btn--primary {
    background: linear-gradient(135deg, #3657CD, #12294B);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(54, 87, 205, 0.25);
}

.tpl-detail-btn--primary:hover {
    box-shadow: 0 4px 16px rgba(54, 87, 205, 0.35);
    color: #ffffff;
}

.tpl-detail-btn--secondary {
    background: var(--color-blue-dark, #12294B);
    color: #ffffff;
}

.tpl-detail-btn--secondary:hover {
    opacity: 0.9;
    color: #ffffff;
}

.tpl-detail-btn--outline {
    background: #ffffff;
    color: #12294B;
    border: 1.5px solid #e0e6ee;
}

.tpl-detail-btn--outline:hover {
    border-color: var(--color-blue-dark, #12294B);
    background: #f8f9fb;
    color: #12294B;
}

/* Hint icon inside buttons */
.tpl-detail-btn .tpl-hint-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
}

.tpl-detail-btn .tpl-hint-icon:hover {
    opacity: 0.8;
}

/* Personal data confirmation */
.tpl-detail-consent {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 20px;
    background: #f8f9fb;
    border-radius: 12px;
    border: 1px solid #e0e6ee;
}

.tpl-detail-consent input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--color-blue-dark, #12294B);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.tpl-detail-consent label {
    font-size: 13px;
    color: #5a6a7e;
    line-height: 1.5;
    cursor: pointer;
}

.tpl-detail-consent a {
    color: var(--color-blue-dark, #3657CD);
    text-decoration: underline;
    text-decoration-color: rgba(54, 87, 205, 0.3);
}

.tpl-detail-consent a:hover {
    text-decoration-color: var(--color-blue-dark, #3657CD);
}

.tpl-detail-error {
    padding: 14px 18px;
    background: #fce4ec;
    border-radius: 10px;
    color: #c62828;
    font-size: 13px;
    font-weight: 500;
}

/* International phone checkbox */
.tpl-detail-card .int-phone-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.tpl-detail-card .int-phone-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-blue-dark, #12294B);
    cursor: pointer;
}

.tpl-detail-card .int-phone-toggle label {
    font-size: 12px;
    color: #9ba8b7;
    font-weight: 400;
    cursor: pointer;
}

/* Confirm modal restyle */
.tpl-confirm-modal .modal-content {
    border-radius: 20px;
    padding: 32px;
    border: none;
    box-shadow: 0 8px 40px rgba(18, 41, 75, 0.15);
}

.tpl-confirm-modal .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0f2f7;
    transition: background 0.2s;
    border: none;
}

.tpl-confirm-modal .modal-close:hover {
    background: #e0e6ee;
}

.tpl-confirm-modal .tpl-confirm-title {
    font-size: 18px;
    font-weight: 700;
    color: #12294B;
    margin: 0 0 12px;
    text-align: center;
}

.tpl-confirm-modal .tpl-confirm-notice-label {
    font-size: 14px;
    font-weight: 600;
    color: #12294B;
    margin: 16px 0 8px;
}

.tpl-confirm-modal .tpl-confirm-notice-text {
    font-size: 13px;
    color: #5a6a7e;
    line-height: 1.6;
    margin: 0;
}

.tpl-confirm-modal .tpl-confirm-buttons {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

/* Sidebar mobile arrow — keep existing functionality */
.tpl-detail-sidebar .sidebar-arrow {
    display: none;
}

/* ===== Responsive ===== */
@media (max-width: 1280px) {
    .tpl-detail-wrap {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .tpl-detail-body {
        flex-direction: column-reverse;
    }

    .tpl-detail-sidebar {
        width: 100%;
    }

    .tpl-detail-preview {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .tpl-detail-wrap {
        padding: 90px 16px 48px;
    }

    .tpl-detail-title {
        font-size: 20px;
    }

    .tpl-detail-card {
        padding: 18px;
    }

    .tpl-detail-preview {
        padding: 18px;
    }

    .tpl-edit-form {
        gap: 18px;
    }

    .tpl-edit-form .django-ckeditor-widget iframe,
    .tpl-edit-form .django-ckeditor-widget {
        max-width: 100% !important;
    }

    .tpl-edit-check-item {
        font-size: 13px;
    }
}

@media (max-width: 640px) {
    .tpl-detail-header-icon {
        display: none;
    }

    .tpl-detail-preview .template-text {
        min-width: unset;
        width: 100%;
    }

    .tpl-edit-label {
        font-size: 12px;
    }

    .tpl-edit-form .input-field,
    .tpl-edit-form input[type="text"],
    .tpl-edit-form textarea,
    .tpl-edit-form select {
        font-size: 16px;
    }
}

/* ---------- Template / Sidename form partials ---------- */

.tpl-form-label {
    margin: 0;
}

.tpl-form-check-row {
    display: flex;
    align-items: center;
    gap: 24px;
}

.sidename-delete-btn {
    align-self: center;
    color: #9aa5b4;
    transition: color 0.15s;
}

.sidename-delete-btn:hover {
    color: #c62828;
}