/**
 * AI-OPTIMIZED LISTING GENERATOR - V2 Styles
 * Uses design-system-v2.css tokens for automatic dark/light theming.
 */

/* ═══════════════════════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════════════════════ */

.page-header h1 {
    font-family: 'Instrument Serif', Georgia, serif;
    font-weight: 400;
    font-size: 42px;
    color: var(--heading);
    letter-spacing: -1px;
}

@media (max-width: 768px) {
    .page-header h1 { font-size: 30px; }
}
@media (max-width: 480px) {
    .page-header h1 { font-size: 28px; }
}

/* ═══════════════════════════════════════════════════════════
   FORM STYLES
   ═══════════════════════════════════════════════════════════ */

.ai-listing-form {
    max-width: 800px;
    margin: 0 auto;
}

.ai-listing-form .form-group {
    margin-bottom: 1.5rem;
}

.ai-listing-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--heading);
}

.ai-listing-form .label-hint {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted);
    display: block;
    margin-top: 0.25rem;
}

.ai-listing-form input[type="text"],
.ai-listing-form textarea,
.ai-listing-form select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--input-text);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-listing-form input[type="text"]:focus,
.ai-listing-form textarea:focus,
.ai-listing-form select:focus {
    outline: none;
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 2px rgba(33, 150, 242, 0.2);
    background: var(--input-bg);
    color: var(--input-text);
}

/* Ensure text stays consistent while typing */
.ai-listing-form input[type="text"]:not(:placeholder-shown),
.ai-listing-form textarea:not(:placeholder-shown) {
    color: var(--input-text);
}

/* Fix browser autofill/autocomplete styling */
.ai-listing-form input[type="text"]:-webkit-autofill,
.ai-listing-form input[type="text"]:-webkit-autofill:hover,
.ai-listing-form input[type="text"]:-webkit-autofill:focus,
.ai-listing-form textarea:-webkit-autofill,
.ai-listing-form textarea:-webkit-autofill:hover,
.ai-listing-form textarea:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
    -webkit-text-fill-color: var(--input-text) !important;
    box-shadow: 0 0 0 1000px var(--bg) inset !important;
    background-color: var(--input-bg) !important;
    caret-color: var(--input-text);
}

/* Placeholder text */
.ai-listing-form input[type="text"]::placeholder,
.ai-listing-form textarea::placeholder {
    color: var(--input-placeholder);
}

.ai-listing-form textarea {
    min-height: 100px;
    resize: vertical;
}

.ai-listing-form select {
    cursor: pointer;
}

.ai-listing-form select optgroup {
    background: var(--bg-alt);
    color: #2196f2;
    font-weight: 600;
}

.ai-listing-form select option {
    background: var(--bg-alt);
    color: var(--text);
    padding: 0.5rem;
}

/* Form Row (side by side fields) */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Checkbox styling */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   PRODUCT SPECS PREVIEW
   ═══════════════════════════════════════════════════════════ */

.product-specs-preview {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-top: 1rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.product-specs-preview h4 {
    color: #2196f2;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.product-specs-preview ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-specs-preview li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.product-specs-preview li:last-child {
    border-bottom: none;
}

.product-specs-preview li strong {
    color: var(--heading);
}

.specs-note {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */

.ai-listing-form .btn-primary {
    background: linear-gradient(135deg, #2196f2 0%, #1976d2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    box-shadow: 0 0 40px rgba(33, 150, 242, 0.25);
}

.ai-listing-form .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 50px rgba(33, 150, 242, 0.35);
}

.ai-listing-form .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-listing-form .btn-secondary {
    background: transparent !important;
    color: #2196f2 !important;
    border: 1px solid rgba(33, 150, 242, 0.3) !important;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-listing-form .btn-secondary:hover {
    background: rgba(33, 150, 242, 0.1) !important;
    border-color: #2196f2 !important;
    color: #2196f2 !important;
}

.button-row {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.button-row .btn-primary {
    flex: 2;
}

.button-row .btn-secondary {
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════
   AI SCORES PANEL
   ═══════════════════════════════════════════════════════════ */

@keyframes ai-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@keyframes ring-glow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 180, 255, 0.3)); }
    50% { filter: drop-shadow(0 0 8px rgba(0, 180, 255, 0.6)); }
}

.ai-scores-panel {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.ai-scores-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 180, 255, 0.2), transparent);
}

.ai-scores-panel h3 {
    color: var(--heading);
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.scores-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.3s, border-color 0.3s;
}

.score-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 14px 14px 0 0;
}

.score-item::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(0, 180, 255, 0.03) 0%, transparent 70%);
    animation: ai-pulse 4s ease-in-out infinite;
    pointer-events: none;
}

.score-item:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 180, 255, 0.25);
}

.score-item .score-ring {
    width: 52px;
    height: 52px;
    min-width: 52px;
    position: relative;
}

.score-item .score-ring svg {
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

.score-item .score-ring .ring-bg {
    fill: none;
    stroke: var(--glass-border);
    stroke-width: 4;
}

.score-item .score-ring .ring-progress {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 1.2s ease-out;
}

.score-item .score-ring .ring-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.score-item .score-info {
    flex: 1;
    min-width: 0;
}

.score-item .score-label {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    margin-right: 0.5rem;
}

.score-item .score-desc {
    font-size: 0.75rem;
    color: var(--muted);
    letter-spacing: 0.3px;
}

/* Score colors — excellent (AI blue) */
.score-excellent::before { background: linear-gradient(90deg, #00b4ff, #0066ff); }
.score-excellent:hover { box-shadow: 0 4px 24px rgba(0, 150, 255, 0.2), 0 0 40px rgba(0, 120, 255, 0.08); }
.score-excellent .ring-progress { stroke: #00b4ff; animation: ring-glow 3s ease-in-out infinite; }
.score-excellent .ring-value { color: #00ccff; }
.score-excellent .score-label { color: #66d4ff; }

/* Score colors — good (lighter blue) */
.score-good::before { background: linear-gradient(90deg, #4da8da, #7ec8e3); }
.score-good:hover { box-shadow: 0 4px 20px rgba(77, 168, 218, 0.2); }
.score-good .ring-progress { stroke: #4da8da; filter: drop-shadow(0 0 4px rgba(77, 168, 218, 0.4)); }
.score-good .ring-value { color: #4da8da; }
.score-good .score-label { color: #7ec8e3; }

/* Score colors — fair (amber) */
.score-fair::before { background: linear-gradient(90deg, #FFC107, #FFD54F); }
.score-fair:hover { box-shadow: 0 4px 20px rgba(255, 193, 7, 0.15); }
.score-fair .ring-progress { stroke: #FFC107; filter: drop-shadow(0 0 4px rgba(255, 193, 7, 0.4)); }
.score-fair .ring-value { color: #FFC107; }
.score-fair .score-label { color: #FFD54F; }

/* Score colors — poor (red) */
.score-poor::before { background: linear-gradient(90deg, #f44336, #E57373); }
.score-poor:hover { box-shadow: 0 4px 20px rgba(244, 67, 54, 0.15); }
.score-poor .ring-progress { stroke: #f44336; filter: drop-shadow(0 0 4px rgba(244, 67, 54, 0.4)); }
.score-poor .ring-value { color: #f44336; }
.score-poor .score-label { color: #E57373; }

/* Score total + summary (independent scorer) */
.scores-total {
    text-align: center;
    margin-bottom: 1.25rem;
}
.scores-total .total-number {
    font-size: 2.8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.scores-total .total-label {
    font-size: 1rem;
    color: var(--muted);
    margin-left: 2px;
}
.score-excellent-text { color: #00ccff; }
.score-good-text { color: #4da8da; }
.score-fair-text { color: #FFC107; }
.score-poor-text { color: #f44336; }

.scores-summary {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.score-reason {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.5;
    margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════
   OUTPUT SECTIONS
   ═══════════════════════════════════════════════════════════ */

.ai-listing-output {
    padding: 1rem 0;
}

/* Etsy Attributes Helper */
.attributes-helper .attributes-select {
    margin-bottom: 0.75rem;
}
.attributes-helper .attributes-select strong,
.attributes-helper .covered-label {
    font-size: 0.85rem;
    color: var(--muted);
    display: block;
    margin-bottom: 0.5rem;
}
.attribute-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.attribute-chip {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    background: rgba(0, 180, 255, 0.1);
    border: 1px solid rgba(0, 180, 255, 0.25);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #00ccff;
}
.attributes-covered {
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}
.covered-list {
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.6;
}

.output-section {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.output-section h3 {
    color: #2196f2;
    font-size: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.output-section .char-count,
.output-section .tag-count {
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted);
}

.output-content {
    background: var(--glass);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.title-output p {
    font-size: 1.1rem;
    color: var(--heading);
    margin: 0;
    line-height: 1.5;
}

.title-analysis {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--glass-border);
}

.title-analysis small {
    color: var(--muted);
}

.description-output pre {
    font-family: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    font-size: 0.95rem;
}

/* Tags grid */
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.5rem;
}

.tag-item {
    background: rgba(33, 150, 242, 0.06);
    border: 1px solid rgba(33, 150, 242, 0.15);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tag-number {
    color: var(--faint);
    font-size: 0.8rem;
}

.tag-text {
    color: var(--heading);
    flex: 1;
}

.tag-length {
    color: var(--faint);
    font-size: 0.75rem;
}

/* Alt tags list */
.alt-tags-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.alt-tag-item {
    background: var(--glass);
    border-radius: 4px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alt-number {
    color: #2196f2;
    font-weight: 600;
    min-width: 25px;
}

.alt-text {
    color: var(--text);
    flex: 1;
    line-height: 1.4;
}

.alt-length {
    color: var(--faint);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* Keywords grid */
.keywords-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .keywords-grid {
        grid-template-columns: 1fr;
    }
}

.keywords-column h4 {
    color: var(--heading-sub);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.keywords-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.keywords-column li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text);
}

/* Copy button */
.copy-btn {
    background: transparent;
    color: #2196f2;
    border: 1px solid rgba(33, 150, 242, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: rgba(33, 150, 242, 0.08);
    border-color: #2196f2;
}

.copy-btn.copied {
    background: #2196f2;
    color: white;
    border-color: #2196f2;
}

/* Description Actions (Copy + GPSR buttons) */
.description-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* GPSR Button */
.gpsr-btn {
    background: transparent;
    color: #ffb74d;
    border: 1px solid #ffb74d;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.gpsr-btn:hover {
    background: rgba(255, 183, 77, 0.1);
}

.gpsr-btn.gpsr-added {
    background: #ffb74d;
    color: var(--bg);
    border-color: #ffb74d;
    cursor: default;
}

.gpsr-btn:disabled {
    opacity: 0.8;
}

/* Copy All Button */
.copy-all-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(33, 150, 242, 0.06);
    border: 2px solid rgba(33, 150, 242, 0.2);
    border-radius: 12px;
}

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

.copy-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 50px rgba(33, 150, 242, 0.35);
}

.copy-all-btn.copied {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
}

.copy-all-btn .copy-icon {
    font-size: 1.2rem;
}

.copy-all-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════
   PREVIEW MODE
   ═══════════════════════════════════════════════════════════ */

.ai-listing-preview {
    padding: 1rem 0;
}

.preview-banner {
    background: rgba(255, 193, 7, 0.08);
    border: 1px solid rgba(255, 193, 7, 0.25);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.preview-banner h3 {
    color: #FFC107;
    margin-bottom: 0.5rem;
}

.preview-banner p {
    color: var(--text);
    margin: 0;
}

.preview-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.preview-section h4 {
    color: #2196f2;
    margin-bottom: 0.75rem;
}

.preview-title {
    font-size: 1.1rem;
    color: var(--heading);
}

.preview-description {
    font-family: inherit;
    white-space: pre-wrap;
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--glass);
    padding: 1rem;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════
   GENERATING STATE
   ═══════════════════════════════════════════════════════════ */

.generating-state {
    text-align: center;
    padding: 3rem 1rem;
}

.spinner-large {
    width: 50px;
    height: 50px;
    border: 4px solid var(--glass-border);
    border-top-color: #2196f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.generating-state p {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.generating-note {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Button spinner */
.spinner {
    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 1s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   ERROR STATE
   ═══════════════════════════════════════════════════════════ */

.error-message {
    background: rgba(244, 67, 54, 0.08);
    border: 1px solid rgba(244, 67, 54, 0.25);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    color: #f44336;
}

/* ═══════════════════════════════════════════════════════════
   EU GPSR Compliance Option Styles
   ═══════════════════════════════════════════════════════════ */

.gpsr-option {
    background: rgba(33, 150, 242, 0.06);
    border: 1px solid rgba(33, 150, 242, 0.15);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
}

.gpsr-option .checkbox-group {
    margin-bottom: 4px;
}

.gpsr-option .gpsr-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 24px;
}

.gpsr-helper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text);
}

/* ═══ INFO ICON TOOLTIPS ═══ */
.info-icon-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    background: #2196f2;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 600;
    margin-left: 6px;
    cursor: help;
    position: relative;
    transition: all 0.2s ease;
}

.info-icon-small:hover {
    background: #1976d2;
    transform: scale(1.1);
}

.info-icon-small::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.3;
    width: max-content;
    max-width: 300px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.info-icon-small::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1001;
    margin-bottom: -2px;
}

.info-icon-small:hover::before,
.info-icon-small:hover::after {
    opacity: 1;
    visibility: visible;
}

.gpsr-helper .info-icon {
    flex-shrink: 0;
    color: #f59e0b;
    margin-top: 2px;
}

.gpsr-helper a {
    color: #2196f2;
    text-decoration: underline;
}

.gpsr-helper a:hover {
    color: #1976d2;
}
