/* CloudSign Templates Styles */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-purple) 100%);
    color: white;
    border-radius: 12px;
}

.page-header h1 {
    color: white;
    margin: 0 0 0.5rem 0;
    font-size: 2rem;
}

.page-header p {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

/* Search Section */
.search-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(11, 83, 148, 0.1);
}

.sort-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.template-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
}

.template-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
    border-color: var(--primary-blue);
}

.template-preview {
    background-color: var(--light-gray);
    padding: 2rem;
    text-align: center;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    border-bottom: 1px solid var(--border-color);
}

.template-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.template-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-gray);
    margin: 0 0 0.5rem 0;
}

.template-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    flex: 1;
}

.template-meta {
    font-size: 0.85rem;
    color: var(--text-gray);
    margin: 0.5rem 0;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.template-card-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.template-category,
.template-badge {
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    padding: 0.45rem 0.65rem;
}

.template-category {
    background: rgba(11, 83, 148, 0.1);
    color: var(--primary-blue);
}

.template-badge {
    background: #e8f3ff;
    color: #0b5ed7;
}

.template-badge.personal {
    background: #e9f8ef;
    color: #1c7c3a;
}

.template-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.template-actions .btn-primary,
.template-actions .btn-secondary {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.template-actions button {
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
}

.btn-danger-outline {
    background: white;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 0.5rem;
}

.btn-danger-outline:hover {
    background: #dc3545;
    color: white;
}

.template-notice {
    border-radius: 8px;
    margin: 0 0 1rem;
    padding: 0.85rem 1rem;
    font-weight: 600;
}

.template-notice.success {
    background: #e9f8ef;
    color: #1c7c3a;
    border: 1px solid #b8e6c7;
}

.template-notice.error {
    background: #fff0f0;
    color: #b42318;
    border: 1px solid #ffc9c9;
}

.template-modal[hidden] {
    display: none;
}

.template-modal {
    align-items: center;
    background: rgba(2, 17, 41, 0.55);
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    padding: 1rem;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 1000;
}

.template-modal-card {
    background: white;
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
    max-width: 560px;
    padding: 1.5rem;
    width: 100%;
}

.template-modal-card h2 {
    margin-top: 0;
}

.template-editor-hint {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.template-modal-card label {
    display: block;
    font-weight: 700;
    margin: 1rem 0 0.35rem;
}

.template-modal-card input,
.template-modal-card textarea,
.template-modal-card select {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font: inherit;
    padding: 0.75rem;
    width: 100%;
}

.template-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* Empty State */
.empty-state-templates {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state-templates h2 {
    color: var(--dark-gray);
    margin-bottom: 0.5rem;
}

.empty-state-templates p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .templates-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .page-header .btn-primary-large {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .search-section {
        flex-direction: column;
    }

    .templates-grid {
        grid-template-columns: 1fr;
    }

    .template-actions {
        flex-direction: column;
    }

    .template-actions .btn-primary,
    .template-actions .btn-secondary {
        width: 100%;
    }
}
