/* WooCommerce AI Manager — Frontend CSS v1.0 */
/* Base style from Simple Frontend Manager, extended with AI panel */

/* ---- Wrapper ---- */
.wam-wrapper {
    max-width: 1200px;
    margin: 2rem auto;
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
}

.wam-header-row, .wam-form-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.wam-main-title { margin: 0 !important; font-size: 2rem !important; font-weight: 900 !important; text-transform: uppercase !important; color: #0f172a !important; }
.wam-back-link { color: #2563eb; text-decoration: none; font-weight: 800; font-size: 0.8rem; text-transform: uppercase; }
.wam-text-right { text-align: right; }
.wam-required { color: #ef4444; margin-left: 2px; }

/* ---- Access denied ---- */
.wam-access-denied {
    padding: 2rem; background: #fff5f5; border: 1px solid #feb2b2;
    color: #c53030; border-radius: 1rem; font-weight: 700; text-align: center;
}

/* ---- Buttons ---- */
.wam-btn {
    display: inline-flex; align-items: center; justify-content: center;
    text-decoration: none !important; cursor: pointer; transition: all 0.2s; border: none;
}
.wam-btn-add {
    background: #2563eb !important; color: #ffffff !important;
    padding: 0.8rem 1.5rem !important; border-radius: 0.75rem !important;
    font-weight: 800 !important; font-size: 0.85rem !important;
    text-transform: uppercase !important; box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2) !important;
}
.wam-btn-add:hover { background: #1d4ed8 !important; transform: translateY(-1px); }
.wam-btn-edit { background: #2563eb !important; color: #ffffff !important; min-width: 80px !important; font-size: 0.75rem; padding: 0.5rem 1rem; border-radius: 0.5rem; font-weight: 800; text-transform: uppercase; }
.wam-btn-delete { background: #fee2e2 !important; color: #dc2626 !important; min-width: 80px !important; font-size: 0.75rem; padding: 0.5rem 1rem; border-radius: 0.5rem; font-weight: 800; text-transform: uppercase; cursor: pointer; }
.wam-btn-media { background: #ffffff !important; border: 1px solid #d1d5db !important; color: #374151 !important; padding: 0.5rem 1.5rem !important; font-size: 0.8rem !important; cursor: pointer; border-radius: 0.5rem; }

/* ---- Form grid ---- */
.wam-form-grid { display: grid; gap: 2rem; }
.wam-field-group { display: flex; flex-direction: column; gap: 0.6rem; }
.wam-field-group label { font-weight: 800; text-transform: uppercase; font-size: 0.75rem; color: #64748b; letter-spacing: 0.025em; }
.wam-field-row-1 { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.wam-field-row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.wam-field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.wam-field-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
/* Krāsa (1/3) + Papildu info AI (2/3) */
.wam-field-row-color-notes { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; }
.wam-field-info { font-size: 0.75rem; color: #94a3b8; font-style: italic; margin: 0; }

/* ---- Title preview ---- */
.wam-title-preview {
    margin-top: 0.5rem;
    padding: 0.5rem 0.875rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    color: #0369a1;
    font-weight: 600;
}

/* ---- AI title toggle checkbox ---- */
.wam-ai-title-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 400 !important;
    text-transform: none !important;
    color: #64748b !important;
    cursor: pointer;
    user-select: none;
}
.wam-ai-title-toggle input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2563eb;
    flex-shrink: 0;
}

/* ---- Attr warning message ---- */
.wam-attr-msg {
    margin-top: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    color: #92400e;
}

.wam-form-grid input[type="text"],
.wam-form-grid input[type="number"],
.wam-form-grid input[type="url"],
.wam-form-grid select {
    padding: 0.8rem 1rem !important; border: 2px solid #f1f5f9 !important;
    border-radius: 0.75rem !important; background: #f8fafc !important;
    font-size: 1rem !important; font-weight: 600 !important; outline: none !important;
}

.wam-multi-select { height: 160px !important; padding: 0.5rem !important; width: 100% !important; }

/* Selected option always visible (even without focus) — gradient trick forces bg in all browsers */
.wam-multi-select option:checked {
    background: linear-gradient(0deg, #2563eb 0%, #2563eb 100%);
    color: #fff;
    font-weight: 600;
}

/* ---- Media uploader ---- */
.wam-media-uploader { background: #fcfcfc; border: 2px dashed #e2e8f0; padding: 1.5rem; border-radius: 1rem; text-align: center; }
.wam-main-image-preview, .wam-gallery-preview { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: flex-start; align-items: flex-start; }
.wam-media-item {
    position: relative !important; flex: 0 0 auto;
    width: 80px; height: 80px;
    border: 2px solid #ffffff; border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    overflow: hidden; background: #f1f5f9;
    display: inline-block !important;
}
.wam-media-item img {
    width: 100% !important; height: 100% !important;
    max-width: 100% !important; max-height: 100% !important;
    object-fit: cover !important; display: block !important;
    border-radius: 0 !important; margin: 0 !important; padding: 0 !important;
}
.wam-media-item--main { width: 120px !important; height: 120px !important; }
.wam-remove-media {
    position: absolute !important; top: 4px !important; right: 4px !important;
    width: 20px !important; height: 20px !important;
    background: rgba(0,0,0,0.5) !important; color: #ffffff !important; border: none !important;
    border-radius: 4px !important; font-size: 12px !important; line-height: 1 !important;
    opacity: 0 !important; transition: opacity 0.15s, background 0.15s !important;
    cursor: pointer !important; display: flex !important; align-items: center !important;
    justify-content: center !important; padding: 0 !important;
    z-index: 20 !important; box-sizing: border-box !important;
}
.wam-remove-media:hover { background: rgba(220,38,38,0.9) !important; opacity: 1 !important; }
.wam-media-item:hover .wam-remove-media { opacity: 1 !important; }

/* ---- Editor ---- */
.wam-editor-wrapper { border: 2px solid #f1f5f9; border-radius: 1rem; overflow: hidden; }

/* ---- Submit ---- */
.wam-submit-row { display: flex; align-items: center; gap: 1.5rem; }
.wam-btn-submit {
    display: inline-flex !important; align-items: center !important; justify-content: center !important;
    background: #10b981 !important; color: #ffffff !important;
    padding: 1.25rem 4rem !important; font-size: 1.1rem !important; line-height: 1 !important;
    border-radius: 1rem !important; border: none !important; font-weight: 900 !important;
    cursor: pointer !important; transition: all 0.2s; box-sizing: border-box !important;
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.3) !important;
}
.wam-btn-submit:hover { background: #059669 !important; transform: translateY(-2px); }
.wam-btn-submit:disabled { opacity: 0.6; transform: none !important; cursor: wait !important; }
.wam-save-status { font-size: 0.9rem; font-weight: 600; color: #059669; }
.wam-btn-view-product {
    display: inline-block; margin-left: 0.75rem;
    background: #0f172a !important; color: #fff !important;
    padding: 0.35rem 0.9rem !important; border-radius: 0.5rem !important;
    font-size: 0.85rem !important; font-weight: 700 !important;
    text-decoration: none !important; border: none !important;
    cursor: pointer !important;
}
.wam-btn-view-product:hover { background: #1e40af !important; color: #fff !important; }

/* ---- List view ---- */
/* ---- Screen options (collapsible column toggle) ---- */
.wam-screen-options {
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    font-size: 0.75rem;
}
.wam-screen-options-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.625rem 1rem;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    text-align: left;
    transition: background 0.15s;
}
.wam-screen-options-toggle:hover { background: #f1f5f9; color: #334155; }
.wam-screen-options.open .wam-screen-options-toggle { background: #eff6ff; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; }
.wam-screen-options-chevron { margin-left: auto; font-size: 0.65rem; }
.wam-screen-options-body {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.75rem 1rem;
    background: #fff;
}
.wam-col-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    color: #334155;
    font-weight: 600;
    user-select: none;
}
.wam-col-toggle input { cursor: pointer; accent-color: #2563eb; }
.wam-btn-save-cols {
    margin-left: auto;
    padding: 0.3rem 0.875rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    letter-spacing: 0.04em;
    transition: background 0.15s;
}
.wam-btn-save-cols:hover { background: #1d4ed8; }
.wam-btn-save-cols.saved { background: #059669; }

/* ---- Nr column ---- */
.wam-col-nr { color: #94a3b8; font-size: 0.8rem; font-weight: 600; text-align: center; }

/* ---- Sortable headers ---- */
#wam-product-table thead th.wam-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
#wam-product-table thead th.wam-sortable:hover { color: #2563eb; }
#wam-product-table thead th.wam-sort-asc::after  { content: ' ↑'; color: #2563eb; }
#wam-product-table thead th.wam-sort-desc::after { content: ' ↓'; color: #2563eb; }

.wam-search-row { margin-bottom: 1.5rem; }
.wam-input-search {
    width: 100% !important; padding: 0.75rem 1rem !important;
    border: 2px solid #f1f5f9 !important; border-radius: 1rem !important;
    font-size: 1rem !important; font-weight: 600 !important;
    background: #ffffff !important; outline: none !important;
}
.wam-table-container { overflow-x: auto; }
.wam-table { width: 100%; border-collapse: collapse; }
.wam-table th { background: #f8fafc; padding: 1rem; text-transform: uppercase; font-size: 0.75rem; font-weight: 800; color: #64748b; border-bottom: 1px solid #f1f5f9; }
.wam-table td { padding: 1rem; border-bottom: 1px solid #f8fafc; vertical-align: middle; }
.wam-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 0.5rem; }
.wam-product-link { color: #1e293b; text-decoration: none; transition: color 0.2s; }
.wam-product-link:hover { color: #2563eb; }
.wam-brand-badge { background: #d1e8ff !important; color: #2271b1 !important; padding: 3px 10px !important; border-radius: 4px !important; font-size: 13px !important; font-weight: 600 !important; }
.wam-price { font-weight: 600; font-size: 1rem; color: #1e293b; }
.wam-actions-btns { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* Select2 overrides */
.select2-container--default .select2-selection--single { height: 46px !important; border: 2px solid #f1f5f9 !important; border-radius: 0.75rem !important; background: #f8fafc !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 44px !important; padding-left: 1rem !important; font-weight: 600; }

/* ============================================================
   AI Panel — WAM specific styles
   ============================================================ */

/* AI notes field */
.wam-ai-notes-group { max-width: 700px; }
.wam-ai-notes-group textarea {
    width: 100%;
    border: 1.5px dashed #a5b4fc;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: #4b5563;
    background: #f8f8ff;
    resize: vertical;
    min-height: 70px;
}
.wam-ai-notes-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
}

/* AI trigger row */
.wam-ai-trigger-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0f4ff 0%, #fafbff 100%);
    border: 2px dashed #c7d7ff;
    border-radius: 1rem;
}

.wam-btn-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    padding: 1rem 2.5rem !important;
    font-size: 1rem !important;
    font-weight: 900 !important;
    border-radius: 0.75rem !important;
    border: none !important;
    cursor: pointer !important;
    letter-spacing: 0.05em;
    box-shadow: 0 8px 15px -3px rgba(102, 126, 234, 0.4) !important;
    transition: all 0.2s;
}
.wam-btn-generate:hover { transform: translateY(-2px); box-shadow: 0 12px 20px -3px rgba(102, 126, 234, 0.5) !important; }
.wam-btn-generate:disabled { opacity: 0.6; transform: none !important; cursor: wait !important; }
.wam-btn-generate.loading { opacity: 0.75; }

.wam-ai-status { font-size: 0.9rem; color: #6b7280; font-style: italic; }

/* AI panel */
.wam-ai-panel {
    background: #f8faff;
    border: 2px solid #e0e7ff;
    border-radius: 1.25rem;
    padding: 1.75rem;
}

.wam-ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.wam-ai-panel-header h3 { margin: 0; font-size: 1.1rem; font-weight: 800; color: #3730a3; }
.wam-ai-meta { font-size: 0.8rem; color: #6b7280; }

/* Language tabs */
.wam-lang-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid #e0e7ff;
    padding-bottom: 0;
}
.wam-lang-tab {
    padding: 0.5rem 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.875rem;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.wam-lang-tab:hover { color: #4f46e5; }
.wam-lang-tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }

/* Language panels */
.wam-lang-panel { display: none; }
.wam-lang-panel.active { display: block; }

.wam-ai-field-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.wam-ai-field-group label { font-weight: 700; font-size: 0.75rem; color: #64748b; text-transform: uppercase; display: flex; justify-content: space-between; }
.wam-ai-field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.wam-ai-panel textarea,
.wam-ai-panel input[type="text"] {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid #c7d7ff;
    border-radius: 0.6rem;
    background: #ffffff;
    font-size: 0.925rem;
    font-weight: 500;
    color: #1e293b;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.wam-ai-panel textarea:focus,
.wam-ai-panel input[type="text"]:focus { border-color: #6366f1; }

.wam-char-count { font-weight: 400; color: #94a3b8; font-size: 0.7rem; text-transform: none; }

/* Apply button */
.wam-ai-apply-row { margin-top: 1rem; }
.wam-btn-apply {
    background: #4f46e5 !important;
    color: #ffffff !important;
    padding: 0.6rem 1.5rem !important;
    border: none !important;
    border-radius: 0.6rem !important;
    font-weight: 700 !important;
    font-size: 0.875rem !important;
    cursor: pointer !important;
    transition: background 0.2s;
}
.wam-btn-apply:hover { background: #4338ca !important; }

/* Color row */
.wam-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1.5px solid #e0e7ff;
    border-radius: 0.75rem;
}
.wam-color-label { font-weight: 700; font-size: 0.875rem; color: #64748b; }
.wam-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #e2e8f0;
    display: inline-block;
    background: #ccc;
}
.wam-btn-apply-small {
    background: #059669 !important;
    color: #ffffff !important;
    padding: 0.4rem 1rem !important;
    border: none !important;
    border-radius: 0.5rem !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    cursor: pointer !important;
    margin-left: auto;
}
.wam-btn-apply-small:hover { background: #047857 !important; }

/* ========================================================================= */
/* COLOR CHIPS — plain hidden-input color field (no Select2)                 */
/* ========================================================================= */
.wam-color-field {
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.5rem;
    background: #fff;
}
.wam-color-input-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.wam-color-input-row input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.4rem;
    font-size: 0.9rem;
}
#wam-color-add {
    flex: 0 0 auto;
    white-space: nowrap !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    background: #2563eb !important;
    color: #fff !important;
    border: none !important;
    border-radius: 0.4rem !important;
    cursor: pointer !important;
}
#wam-color-add:hover { background: #1d4ed8 !important; }
.wam-color-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 0;
}
.wam-color-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.3rem 0.3rem 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}
.wam-color-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 3px;
    background: rgba(0,0,0,0.15);
    color: #1e40af;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.wam-color-chip-remove:hover { background: #dc2626; color: #fff; }

/* ---- Fix WP media modal on frontend (theme CSS breaks layout) ---- */
.media-modal { position: fixed !important; top: 30px !important; left: 30px !important; right: 30px !important; bottom: 30px !important; width: auto !important; height: auto !important; box-sizing: border-box !important; }
.media-modal-backdrop { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; }
.media-modal *, .media-frame * { box-sizing: border-box; }
.media-frame { position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; }
.media-frame-title { height: 50px !important; }
.media-frame-title h1 { padding: 0 16px !important; line-height: 50px !important; font-size: 22px !important; margin: 0 !important; }
.media-frame-router { top: 50px !important; }
.media-frame-content { top: 84px !important; bottom: 61px !important; overflow: auto !important; }
.media-frame-toolbar { bottom: 60px !important; }
.media-toolbar { height: 60px !important; }
.media-modal .attachments-browser .attachments { padding: 8px !important; }
.media-modal .attachment { width: 150px !important; height: 150px !important; }
.media-modal .media-toolbar-secondary, .media-modal .media-toolbar-primary { overflow: visible !important; }

/* ---- Submit row: side-by-side save + view buttons ---- */
.wam-submit-btns {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.wam-btn-view {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    padding: 1.25rem 4rem !important;
    background: #1e293b !important;
    color: #fff !important;
    border-radius: 1rem !important;
    font-weight: 900 !important;
    font-size: 1.1rem !important;
    line-height: 1 !important;
    text-decoration: none !important;
    transition: background 0.15s !important;
    white-space: nowrap !important;
    cursor: pointer !important;
    border: none !important;
    box-sizing: border-box !important;
}
.wam-btn-view:hover { background: #334155 !important; color: #fff !important; }

/* ---- Description preview ---- */
.wam-desc-preview {
    min-height: 80px;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.92rem;
    line-height: 1.7;
    color: #1f2937;
    cursor: default;
}
.wam-desc-preview p { margin: 0 0 0.75em; }
.wam-desc-preview p:last-child { margin-bottom: 0; }
.wam-desc-preview strong { font-weight: 700; }
.wam-desc-preview em { font-style: italic; color: #4b5563; }
.wam-desc-preview h2 { font-size: 1.1rem; font-weight: 800; margin: 0 0 0.5em; color: #0f172a; }
.wam-desc-preview h3 { font-size: 1rem; font-weight: 700; margin: 0 0 0.4em; color: #1e293b; }
.wam-desc-preview ul, .wam-desc-preview ol { padding-left: 1.5em; margin: 0 0 0.75em; }
.wam-desc-preview li { margin-bottom: 0.25em; }
.wam-desc-toggle {
    float: right;
    font-size: 0.75rem;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    color: #6b7280;
    font-weight: 600;
    margin-left: 0.5rem;
}
.wam-desc-toggle:hover { background: #f3f4f6; border-color: #9ca3af; }
