/* =====================================================
   Product Templates Page Styles — V2 Design System
   For: templates.html
   Created: December 1, 2025
   Updated: February 25, 2026 (v2 redesign)
   ===================================================== */

/* Page Background - Uses v2 tokens */
body.templates-page {
    background: var(--bg);
}

/* Templates Container */
.templates-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 24px 32px;
    background: var(--bg);
    min-height: calc(100vh - 200px);
}

/* Page Header */
.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
    gap: 24px;
}

.templates-header-content h1 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    font-size: 32px;
    color: var(--heading);
    margin: 0 0 4px 0;
}

.templates-subtitle {
    color: var(--muted);
    font-size: 16px;
    margin: 0;
}

.btn-add-template {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2196f2, #1976d2);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 0 40px rgba(33, 150, 242, 0.25);
}

.btn-add-template:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 242, 0.3);
}

/* GEO Info Card */
.geo-info-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 32px;
    margin-bottom: 32px;
    border-left: 4px solid #2196f2;
}

.geo-info-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.geo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2196f2;
    color: white;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 6px 12px;
    border-radius: 6px;
}

.geo-info-header h3 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    font-size: 20px;
    color: var(--heading);
    margin: 0;
}

.geo-info-content p {
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    margin: 0 0 24px 0;
}

.geo-benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.geo-benefit {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.benefit-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(33, 150, 242, 0.15);
    color: #2196f2;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.geo-benefit strong {
    display: block;
    color: var(--heading);
    font-size: 15px;
    margin-bottom: 4px;
}

.geo-benefit p {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

/* Templates Section */
.templates-section {
    margin-bottom: 48px;
}

.templates-section h2 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    font-size: 24px;
    color: var(--heading);
    margin: 0 0 24px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-count {
    font-size: 16px;
    color: var(--muted);
    font-weight: 400;
}

.section-subtitle {
    color: var(--muted);
    font-size: 15px;
    margin: -8px 0 24px 0;
}

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

/* Loading State */
.templates-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(33, 150, 242, 0.2);
    border-top-color: #2196f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.templates-loading p {
    color: var(--muted);
    font-size: 15px;
    margin: 0;
}

/* Empty State */
.templates-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 32px;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
}

.empty-icon {
    color: rgba(33, 150, 242, 0.5);
    margin-bottom: 24px;
}

.templates-empty h3 {
    font-size: 20px;
    color: var(--heading);
    margin: 0 0 8px 0;
}

.templates-empty p {
    color: var(--muted);
    font-size: 15px;
    margin: 0 0 24px 0;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.btn-add-template-empty {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #2196f2, #1976d2);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 40px rgba(33, 150, 242, 0.25);
}

.btn-add-template-empty:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(33, 150, 242, 0.3);
}

/* Template Card */
.template-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 24px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--glass-border-hover);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.template-card-header h3 {
    font-size: 17px;
    color: var(--heading);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    padding-right: 8px;
}

.template-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-icon svg {
    display: block;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Edit button - Blue gradient with WHITE icon */
.btn-icon-edit {
    background: linear-gradient(135deg, #2196f2, #1976d2);
    border: none;
    color: white;
}

.btn-icon-edit svg {
    stroke: white;
    fill: none;
}

.btn-icon-edit:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 242, 0.4);
}

/* Delete button */
.btn-icon-delete {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--muted);
}

.btn-icon-delete svg {
    stroke: var(--muted);
    fill: none;
}

.btn-icon-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon-delete:hover svg {
    stroke: #ef4444;
}

.template-preview {
    background: var(--bg-alt);
    border-radius: 8px;
    padding: 8px 16px;
    margin-bottom: 16px;
    flex: 1;
}

.template-preview p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
}

.template-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-usage {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Coming Soon Notice */
.coming-soon-notice {
    background: rgba(33, 150, 242, 0.1);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.coming-soon-badge {
    display: inline-block;
    background: #2196f2;
    color: white;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.coming-soon-notice p {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
    padding: 24px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content-small {
    max-width: 420px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--glass-border);
}

.modal-header h2 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    font-size: 20px;
    color: var(--heading);
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 28px;
    color: var(--muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--glass-strong);
    color: var(--heading);
}

.modal-body {
    padding: 32px;
}

.modal-body p {
    color: var(--text);
    font-size: 15px;
    margin: 0 0 8px 0;
}

.warning-text {
    color: #dc3545;
    font-size: 14px;
}

/* Form Styles */
#templateForm {
    padding: 32px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 4px;
}

.required {
    color: #dc3545;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--input-border);
    border-radius: 12px;
    font-size: 15px;
    color: var(--input-text);
    background: var(--input-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px rgba(33, 150, 242, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 200px;
}

.form-hint {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding: 24px 32px;
    border-top: 1px solid var(--glass-border);
    background: var(--bg-alt);
    border-radius: 0 0 20px 20px;
}

.btn-cancel {
    padding: 12px 24px;
    border: 1px solid var(--glass-border);
    background: var(--card-bg);
    color: var(--heading);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancel:hover {
    background: var(--glass-strong);
    border-color: var(--glass-border-hover);
}

.btn-save {
    padding: 12px 24px;
    border: none;
    background: linear-gradient(135deg, #2196f2, #1976d2);
    color: white;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 40px rgba(33, 150, 242, 0.25);
}

.btn-save:hover {
    background: linear-gradient(135deg, #1976d2, #1565c0);
}

.btn-save:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-delete {
    padding: 12px 24px;
    border: none;
    background: #dc3545;
    color: white;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: #c82333;
}

.loading-spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .templates-container {
        padding: 100px 16px 24px;
    }

    .templates-header {
        flex-direction: column;
        align-items: stretch;
    }

    .templates-header-content h1 {
        font-size: 26px;
    }

    .btn-add-template {
        width: 100%;
        justify-content: center;
    }

    .geo-benefits {
        grid-template-columns: 1fr;
    }

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

    .modal-overlay {
        padding: 16px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .btn-cancel,
    .btn-save,
    .btn-delete {
        width: 100%;
        justify-content: center;
    }
}

/* =====================================================
   How To Video Card (Collapsible)
   ===================================================== */

.howto-video-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 32px;
    overflow: hidden;
}

.howto-video-header {
    width: 100%;
    padding: 24px 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.howto-video-header:hover {
    background: rgba(33, 150, 242, 0.08);
}

.howto-video-header h3 {
    font-size: 18px;
    color: var(--heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.howto-video-header .play-icon {
    color: #2196f2;
}

.howto-video-header .chevron-icon {
    color: var(--muted);
    transition: transform 0.3s ease;
}

.howto-video-header[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}

.howto-video-content {
    padding: 24px;
    border-top: 1px solid var(--glass-border);
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.howto-video-content.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    border-top: none;
}

.howto-video-content video {
    width: 100%;
    max-width: 800px;
    display: block;
    margin: 0 auto;
    border-radius: 12px;
    background: #000;
}

/* =====================================================
   EU GPSR Badge & Form Styles
   ===================================================== */

/* Badge on template cards */
.gpsr-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
}

/* Optional label in form */
.optional-label {
    font-weight: 400;
    color: var(--muted);
    font-size: 13px;
}
