/**
 * RiskShield Component Styles - Refined for theme compliance and resolution
 */

.rs-app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

/* Grid Pattern Background - Using theme color with low opacity */
.rs-app::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(rgba(243, 123, 32, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(243, 123, 32, 0.03) 1px, transparent 1px);
    background-size: 30px 30px;
    pointer-events: none;
}

.rs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    z-index: 10;
}

.rs-header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.rs-back-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.rs-back-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.rs-title-meta h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.rs-title-meta p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

.rs-main {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    z-index: 5;
}

.rs-view-section {
    display: none;
    height: 100%;
}

.rs-view-section.active {
    display: block;
}

.rs-layout {
    display: grid;
    grid-template-columns: minmax(400px, 480px) 1fr;
    gap: 2.5rem;
    width: 100%;
}

/* Glassmorphism Card Style */
.rs-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.rs-section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.rs-section-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-transparent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
}

.rs-section-title h2 {
    font-size: 1rem;
    margin: 0;
}

.rs-section-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
    position: relative;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.form-group label svg {
    color: var(--accent-color);
    opacity: 0.8;
}

.form-group input,
.form-group .ts-wrapper {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    color: var(--text-primary) !important;
    padding: 0.6rem 0.8rem !important;
    font-size: 0.85rem !important;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group .ts-wrapper.focus {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 2px var(--accent-transparent);
}

.form-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.form-group.has-error input,
.form-group.has-error .ts-wrapper {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

/* Specific class to avoid global .error-message style conflicts */
.rs-error-message {
    color: #ef4444 !important;
    font-size: 0.7rem !important;
    margin-top: 0.25rem !important;
    display: block !important;
    animation: fadeIn 0.15s ease-out !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    text-align: left !important;
    box-shadow: none !important;
}

/* Inline Loading Animation for fields */
.form-group.is-loading::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 2.22rem;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(156, 163, 175, 0.2);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: rs-spin 0.8s linear infinite;
    z-index: 100;
    pointer-events: none;
}

.form-group.is-loading input,
.form-group.is-loading .ts-wrapper {
    opacity: 0.6;
    pointer-events: none;
}

.rs-btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
    box-shadow: 0 4px 12px var(--accent-transparent);
}

.rs-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    opacity: 0.9;
}

.rs-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Result Column Placeholder */
.rs-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.rs-placeholder-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.rs-placeholder h2 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
}

.rs-placeholder p {
    font-size: 0.9rem;
    max-width: 300px;
    line-height: 1.5;
}

/* TomSelect Overrides for Themes */
.ts-control {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: var(--text-primary) !important;
    min-height: auto !important;
}

.ts-control input {
    color: var(--text-primary) !important;
}

.ts-dropdown {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--text-primary) !important;
    border-radius: 12px !important;
    margin-top: 8px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4) !important;
    opacity: 1 !important;
    z-index: 1000 !important;
}

.ts-dropdown .active {
    background: var(--accent-transparent) !important;
    color: var(--text-primary) !important;
}

.ts-dropdown .option {
    padding: 8px 12px !important;
}

.ts-wrapper.multi .ts-control>div {
    background: var(--accent-color) !important;
    color: white !important;
    border-radius: 6px !important;
    padding: 2px 8px !important;
    font-size: 0.8rem !important;
    margin: 2px !important;
}

.ts-wrapper.multi .ts-control>div .remove {
    border-left: 1px solid rgba(255, 255, 255, 0.2) !important;
    margin-left: 6px !important;
}

/* Result Card */
.rs-result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 2.5rem;
    animation: fadeIn 0.4s ease-out;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rs-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2.5rem;
}

.rs-risk-meter {
    text-align: right;
}

.rs-score-large {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}

.rs-level-badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 0.75rem;
}

.rs-analysis-content {
    display: grid;
    gap: 2rem;
}

.rs-detail-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1.5rem;
    align-items: baseline;
}

.rs-detail-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.rs-detail-value {
    color: var(--text-primary);
    line-height: 1.6;
}

/* Result Header Text Colors */
.rs-result-product-name {
    margin: 0;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.rs-score-total {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Guidelines Table */
.rs-guidelines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.rs-guidelines-table thead tr {
    background: var(--bg-tertiary);
}

.rs-guidelines-table th {
    padding: 0.6rem;
    text-align: left;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.rs-guidelines-table td {
    text-align: center;
}

/* Payment Methods */
.rs-pm-item {
    padding: 0.8rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rs-pm-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--glass-shadow, rgba(0, 0, 0, 0.1));
}

.rs-pm-name {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.rs-pm-status {
    font-size: 0.7rem;
    font-weight: 600;
}

.rs-pm-status.allowed {
    color: var(--color-success);
}

.rs-pm-status.restricted {
    color: var(--color-error);
}
/* Management/Admin Views */
.rs-tabs {
    display: flex;
    gap: 1rem;
    margin-top: 10px;
}

.rs-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.rs-tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.rs-tab-btn.active {
    color: var(--accent-color);
    background: var(--accent-transparent);
}

.rs-admin-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    height: 100%;
}

.rs-admin-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.rs-prompt-editor {
    width: 100%;
    height: 400px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 1.5rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.rs-prompt-editor:focus {
    border-color: var(--accent-color);
}

.rs-file-manager {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-light);
}

.rs-file-list {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.rs-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
}

.rs-file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rs-file-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.rs-file-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.rs-file-actions {
    display: flex;
    gap: 0.5rem;
}

.rs-btn-icon-danger {
    padding: 4px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: #f43f5e;
    cursor: pointer;
    transition: background 0.2s;
}

.rs-btn-icon-danger:hover {
    background: rgba(244, 63, 94, 0.1);
}

.rs-upload-box {
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.rs-upload-box:hover {
    border-color: var(--accent-color);
    background: var(--accent-transparent);
}

.rs-upload-box p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.5rem 0 0 0;
}

.rs-admin-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.rs-btn-ghost {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.rs-btn-ghost:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

/* Dynamic Fields Management Styles */
.rs-config-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.rs-field-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.rs-field-item {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.rs-field-info h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.rs-option-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.rs-option-tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.rs-add-field-card {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-light);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.rs-add-field-card h3 {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.rs-field-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rs-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rs-input-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.rs-input-group input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: var(--text-primary);
    font-size: 0.85rem;
}

.rs-badge-static {
    background: var(--accent-transparent);
    color: var(--accent-color);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 700;
    margin-left: 0.5rem;
    border: 1px solid var(--accent-color-transparent);
}

.rs-btn-icon-ghost {
    padding: 4px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: default;
    opacity: 0.7;
}

.rs-header-info h2 {
    margin: 0;
    font-size: 1rem;
}

.rs-header-info p {
    margin: 2px 0 0 0;
}

.field-hidden {
    opacity: 0.6;
    background: rgba(255, 255, 255, 0.02) !important;
}

.field-hidden h4 {
    color: var(--text-muted);
    text-decoration: line-through;
}

.rs-btn-icon-toggle {
    padding: 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rs-btn-icon-toggle:hover {
    background: rgba(45, 212, 191, 0.1);
    border-color: var(--accent-color);
}

.field-hidden .rs-btn-icon-toggle {
    color: #64748b;
}

.rs-field-actions {
    display: flex;
    gap: 8px;
}

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

/* Processing Spinner */
.rs-processing-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    gap: 1.5rem;
    color: var(--text-secondary);
    text-align: center;
}

.rs-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--accent-transparent);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: rs-spin 1s linear infinite;
    box-shadow: 0 0 15px var(--accent-glow);
}

@keyframes rs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.rs-processing-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}
