/* UTM Generator Styles - Reset and Base */
.utm-generator-container * {
    box-sizing: border-box;
}

.utm-generator-container button {
    font-family: inherit;
}

/* Container and Wrapper */
.utm-generator-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1a1a1a;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

/* Header Wrapper */
.utm-header-wrapper {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

/* Two Column Layout - High Specificity */
.utm-generator-container .utm-content-wrapper {
    display: grid !important;
    grid-template-columns: minmax(500px, 1fr) 380px !important;
    gap: 24px !important;
    align-items: start !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Main Column */
.utm-generator-container .utm-main-column {
    background: #ffffff !important;
    border-radius: 16px !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    min-width: 0 !important; /* Prevent overflow */
    display: block !important;
}

/* Sidebar Column */
.utm-generator-container .utm-sidebar-column {
    position: sticky !important;
    top: 20px !important;
    display: block !important;
}

/* Header Section */
.utm-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 32px;
    text-align: center;
    color: white;
}

.utm-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: white;
}

.utm-icon {
    width: 32px;
    height: 32px;
}

.utm-description {
    margin: 0;
    font-size: 16px;
    opacity: 0.95;
    color: white;
}

/* Form Section */
.utm-form {
    padding: 32px;
    overflow: visible;
}

.utm-section {
    margin-bottom: 32px;
    overflow: visible;
}

.utm-field-group {
    margin-bottom: 20px;
    position: relative;
    overflow: visible;
}

.utm-section-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    color: #2d3748;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Field Groups */
.utm-field-group {
    margin-bottom: 20px;
}

.utm-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #4a5568;
}

.utm-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: #f7fafc;
    box-sizing: border-box;
}

.utm-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.utm-input:valid {
    border-color: #e2e8f0;
}

.utm-input:invalid:not(:placeholder-shown) {
    border-color: #fc8181;
}

/* Tooltip */
.utm-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    color: #718096;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.utm-tooltip svg {
    width: 14px;
    height: 14px;
}

.utm-tooltip:hover {
    color: #667eea;
    opacity: 1;
}

.utm-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: -100px;
    background: #2d3748;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.6;
    width: 280px;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    text-align: left;
    white-space: normal;
    word-wrap: break-word;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.utm-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Adjust position for edge cases */
.utm-field-group:nth-child(1) .utm-tooltip::after {
    bottom: auto;
    top: calc(100% + 10px);
}

.utm-field-group:nth-child(1) .utm-tooltip::before {
    bottom: auto;
    top: calc(100% + 4px);
    border-top-color: transparent;
    border-bottom-color: #2d3748;
}

/* For fields on the right side, adjust tooltip position */
.utm-field-group:last-child .utm-tooltip::after {
    left: auto;
    right: -20px;
}

/* Tooltip arrow */
.utm-tooltip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 7px;
    border: 6px solid transparent;
    border-top-color: #2d3748;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.utm-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Ensure tooltips are not cut off by parent containers */
.utm-form,
.utm-section,
.utm-field-group,
.utm-main-column,
.utm-generator-container {
    overflow: visible !important;
}

/* Add padding to accommodate tooltips */
.utm-section {
    padding-top: 15px;
}

.utm-field-group:first-child {
    margin-top: 10px;
}

/* Error Messages */
.utm-error-message {
    display: none;
    color: #e53e3e;
    font-size: 13px;
    margin-top: 4px;
}

.utm-field-group.error .utm-input {
    border-color: #fc8181;
}

.utm-field-group.error .utm-error-message {
    display: block;
}

/* Optional Fields */
.utm-optional-section .utm-section-title {
    cursor: pointer;
    user-select: none;
}

.utm-toggle-optional {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.utm-toggle-optional[aria-expanded="true"] {
    transform: rotate(180deg);
}

.utm-optional-fields {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Buttons */
.utm-button-group {
    display: flex;
    gap: 12px;
    margin-top: 28px;
}

.utm-btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.utm-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.utm-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.25);
}

.utm-btn-secondary {
    background: #edf2f7;
    color: #4a5568;
}

.utm-btn-secondary:hover {
    background: #e2e8f0;
}

/* Result Section */
.utm-result-section {
    padding: 32px;
    border-top: 1px solid #e2e8f0;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.utm-result-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #e2e8f0;
}

.utm-result-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.utm-result-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.utm-copy-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.utm-copy-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.25);
}

.utm-copy-btn.copied {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.utm-copy-btn.copied .utm-copy-icon {
    display: none;
}

.utm-copy-btn.copied .utm-check-icon {
    display: block !important;
    animation: checkmark 0.3s ease;
}

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(-45deg);
    }
    50% {
        transform: scale(1.2) rotate(0deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* Result Preview */
.utm-result-preview {
    padding: 12px 16px;
    background: #f7fafc;
    border-radius: 8px;
    font-size: 13px;
    word-break: break-all;
}

.utm-result-preview strong {
    color: #2d3748;
    margin-right: 8px;
}

/* Stats Section */
.utm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.utm-stat-item {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.utm-stat-label {
    display: block;
    font-size: 12px;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.utm-stat-value {
    font-size: 14px;
    color: #2d3748;
    font-weight: 600;
}

/* Presets Section - Sidebar */
.utm-presets-section {
    background: white !important;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.05);
    width: 100%;
    box-sizing: border-box;
}

.utm-presets-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 8px;
}

.utm-presets-explanation {
    background: #f7fafc;
    border-left: 4px solid #667eea;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.utm-presets-explanation p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #4a5568;
}

.utm-presets-explanation p:last-child {
    margin-bottom: 0;
}

.utm-presets-explanation strong {
    color: #2d3748;
}

.utm-presets-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.utm-preset-btn {
    padding: 12px 16px;
    background: white !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #4a5568 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    text-align: left !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.utm-preset-btn:hover {
    border-color: #667eea !important;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%) !important;
    transform: translateX(4px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15) !important;
    color: #667eea !important;
}

.utm-preset-btn:active {
    transform: translateX(2px) !important;
}

.utm-preset-btn svg {
    flex-shrink: 0 !important;
    width: 18px !important;
    height: 18px !important;
}

/* Default icon color for stroke-based icons */
.utm-preset-btn svg[stroke] {
    color: #667eea !important;
}

/* Google icon should keep its original colors */
.utm-preset-btn svg[fill] {
    /* Keep original fill colors for brand icons like Google */
}

/* Dark Theme (optional) */
.utm-generator-container.dark-theme {
    color: #e2e8f0;
}

.utm-generator-container.dark-theme .utm-generator-wrapper {
    background: #1a202c;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.utm-generator-container.dark-theme .utm-header {
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%);
}

.utm-generator-container.dark-theme .utm-section-title,
.utm-generator-container.dark-theme .utm-label {
    color: #e2e8f0;
}

.utm-generator-container.dark-theme .utm-input {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.utm-generator-container.dark-theme .utm-input:focus {
    background: #374151;
    border-color: #7c3aed;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .utm-content-wrapper {
        grid-template-columns: 1fr 340px;
    }
}

@media (max-width: 1024px) {
    .utm-content-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .utm-sidebar-column {
        position: relative;
        top: 0;
        max-height: none;
    }
    
    .utm-presets-section {
        margin-top: 0;
    }
    
    .utm-presets-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .utm-generator-container {
        padding: 10px;
    }
    
    .utm-header-wrapper,
    .utm-main-column,
    .utm-presets-section {
        border-radius: 12px;
    }
    
    .utm-header,
    .utm-form,
    .utm-result-section,
    .utm-presets-section {
        padding: 20px;
    }
    
    .utm-title {
        font-size: 24px;
    }
    
    .utm-button-group {
        flex-direction: column;
    }
    
    .utm-presets-grid {
        grid-template-columns: 1fr;
    }
    
    .utm-stats {
        grid-template-columns: 1fr;
    }
    
    .utm-preset-hint {
        display: none !important;
    }
}

/* Loading State */
.utm-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.utm-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    border: 3px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
