/**
 * Frontend Styles for Email Signature Generator
 */

.esg-frontend-generator {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.esg-generator-header {
    text-align: center;
    margin-bottom: 40px;
}

.esg-generator-header h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 300;
}

.esg-generator-header p {
    color: #7f8c8d;
    font-size: 1.1em;
    margin: 0;
}

.esg-generator-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: start;
}

.esg-generator-form {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
}

.esg-form-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ecf0f1;
}

.esg-form-section:last-child {
    border-bottom: none;
}

/* Logo Options Styles */
.esg-logo-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 10px;
}

.esg-logo-option {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    background: #fafbfc;
    transition: all 0.3s ease;
}

.esg-logo-option:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.esg-logo-option input[type="radio"] {
    margin-right: 10px;
    margin-bottom: 0;
}

.esg-logo-option label {
    font-weight: 500;
    color: #2c3e50;
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-bottom: 0;
}

.esg-upload-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.esg-upload-container input[type="file"] {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
}

.esg-upload-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s;
    align-self: flex-start;
}

.esg-upload-btn:hover {
    background: #2980b9;
}

#esg-logo-upload-name {
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 5px;
}

.esg-logo-option input[type="url"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 8px;
    display: none;
    /* Initially hidden, controlled by JavaScript */
}

.esg-logo-option input[type="url"]:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.esg-form-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: 600;
}

.esg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.esg-form-group {
    display: flex;
    flex-direction: column;
}

.esg-form-group label {
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.esg-form-group input,
.esg-form-group textarea,
.esg-form-group select {
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.esg-form-group input:focus,
.esg-form-group textarea:focus,
.esg-form-group select:focus {
    outline: none;
    border-color: #3498db;
}

.esg-form-group small {
    color: #7f8c8d;
    font-size: 0.8em;
    margin-top: 5px;
}

.esg-template-selector {
    margin-top: 20px;
}

.esg-template-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
    justify-content: center;
}

.esg-category-btn {
    padding: 10px 20px;
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
        linear-gradient(135deg, #667eea 0%, #764ba2 100%) border-box;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.9em;
    font-weight: 600;
    color: #2c3e50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.esg-category-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.esg-category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.esg-category-btn:hover::before {
    left: 0;
}

.esg-category-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.esg-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    scrollbar-width: thin;
    scrollbar-color: #667eea #f0f0f0;
}

/* Custom scrollbar for WebKit browsers */
.esg-template-grid::-webkit-scrollbar {
    width: 8px;
}

.esg-template-grid::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

.esg-template-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.esg-template-grid::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.esg-template-option {
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.esg-template-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.esg-template-label {
    display: block;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 12px;
    padding: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    position: relative;
    overflow: hidden;
}

.esg-template-label::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: -1;
}

.esg-template-label::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.esg-template-option:hover .esg-template-label {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.esg-template-option input[type="radio"]:checked+.esg-template-label {
    border-color: transparent;
    background: white;
    box-shadow: 0 8px 16px rgba(39, 174, 96, 0.2);
}

.esg-template-option input[type="radio"]:checked+.esg-template-label::before {
    opacity: 1;
}

.esg-template-option input[type="radio"]:checked+.esg-template-label::after {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.esg-template-option.selected .esg-template-label {
    border-color: transparent;
    background: white;
    box-shadow: 0 8px 16px rgba(39, 174, 96, 0.2);
}

.esg-template-option.selected .esg-template-label::before {
    opacity: 1;
}

.esg-template-option.selected .esg-template-label::after {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.esg-template-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    border-radius: 8px 8px 0 0;
    padding: 15px;
    margin: 0;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.esg-template-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.esg-template-option:hover .esg-template-preview::before {
    opacity: 1;
}

.esg-template-preview-content {
    text-align: left;
    font-size: 0.85em;
    line-height: 1.3;
    width: 100%;
    position: relative;
    z-index: 1;
}

.esg-template-name {
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    font-size: 0.95em;
    padding: 12px 15px;
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-radius: 0 0 8px 8px;
    margin: 0;
    border-top: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.esg-template-option:hover .esg-template-name {
    background: linear-gradient(to bottom, #ffffff 0%, #e9ecef 100%);
    color: #667eea;
}

.esg-form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.esg-generate-btn,
.esg-preview-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.esg-generate-btn {
    background: #27ae60;
    color: #fff;
}

.esg-generate-btn:hover {
    background: #219a52;
}

.esg-preview-btn {
    background: #3498db;
    color: #fff;
}

.esg-preview-btn:hover {
    background: #2980b9;
}

.esg-generator-preview {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
    position: sticky;
    top: 20px;
}

.esg-preview-header h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.esg-preview-header p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.esg-signature-preview {
    border: 2px dashed #bdc3c7;
    border-radius: 6px;
    padding: 20px;
    min-height: 200px;
    background: #f8f9fa;
}

.esg-preview-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #7f8c8d;
    text-align: center;
}

.esg-preview-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.esg-export-btn,
.esg-copy-btn {
    padding: 8px 16px;
    border: 2px solid #3498db;
    background: #fff;
    color: #3498db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.esg-export-btn:hover,
.esg-copy-btn:hover {
    background: #3498db;
    color: #fff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .esg-generator-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .esg-form-row {
        grid-template-columns: 1fr;
    }

    .esg-template-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .esg-form-actions {
        flex-direction: column;
    }

    .esg-generator-header h2 {
        font-size: 2em;
    }
}

/* Template Preview Styles */
.esg-signature-preview table {
    width: 100%;
    border-collapse: collapse;
}

.esg-signature-preview img {
    max-width: 100%;
    height: auto;
}

/* Loading State */
.esg-loading {
    position: relative;
}

.esg-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: esg-spin 1s linear infinite;
}

@keyframes esg-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}