/* ==========================================================================
   AI Safe Prompt Converter - Design System & Modern Styling
   ========================================================================== */

:root {
    --bg-primary: #0a0d18;
    --bg-card: rgba(20, 26, 48, 0.7);
    --bg-card-hover: rgba(28, 36, 66, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(147, 51, 234, 0.3);

    --accent-purple: #9333ea;
    --accent-indigo: #6366f1;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-code: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow-purple: 0 0 25px rgba(147, 51, 234, 0.35);
    --shadow-glow-cyan: 0 0 25px rgba(6, 182, 212, 0.35);
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Global Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Dynamic Animated Background Blobs */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.25;
    animation: floatBlob 18s ease-in-out infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--accent-purple), var(--accent-indigo));
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-cyan), #3b82f6);
    bottom: -150px;
    right: -100px;
    animation-delay: -6s;
}

.blob-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--accent-rose), var(--accent-purple));
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -12s;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(50px, 40px) scale(1.1); }
    100% { transform: translate(-40px, 60px) scale(0.95); }
}

/* App Container Layout */
.app-container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* Header Styles */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    flex-wrap: wrap;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-indigo));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    box-shadow: var(--shadow-glow-purple);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-pro {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border-radius: var(--radius-full);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.brand-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.safety-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.indicator-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.indicator-dot.green {
    background-color: var(--accent-emerald);
    box-shadow: 0 0 10px var(--accent-emerald);
}

/* Card Component Base */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.card-title i {
    font-size: 18px;
    color: var(--accent-indigo);
}

.output-card .card-title i {
    color: var(--accent-emerald);
}

.card-title h2, .card-title h3 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 600;
}

/* Main Grid Layout */
.converter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

/* Preset Chips */
.preset-bar {
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
}

.preset-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.preset-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-fast);
}

.preset-chip:hover {
    background: rgba(147, 51, 234, 0.2);
    border-color: var(--accent-purple);
    color: #fff;
}

/* Mode Selector Buttons */
.mode-selector {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    gap: 4px;
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.mode-btn:not(.active):hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* Editor Wrapper & Textareas */
.editor-wrapper {
    flex: 1;
    min-height: 280px;
    position: relative;
    display: flex;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 280px;
    padding: 20px 24px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-code);
    font-size: 14px;
    line-height: 1.7;
    resize: none;
}

textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-main);
    font-style: italic;
}

#sanitizedPrompt {
    background: rgba(0, 0, 0, 0.15);
    color: #a7f3d0;
}

/* Replaced Badges Bar */
.replaced-badges-bar {
    padding: 10px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-height: 44px;
}

.empty-badge-text {
    font-size: 12px;
    color: var(--text-muted);
}

.badge-swap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fda4af;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-family: var(--font-code);
    font-weight: 500;
}

.badge-swap i {
    font-size: 9px;
    color: var(--accent-emerald);
}

.badge-swap .safe-term {
    color: #6ee7b7;
    font-weight: 600;
}

/* Card Footers */
.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(0, 0, 0, 0.15);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.text-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.text-stats strong {
    color: var(--text-secondary);
}

.flag-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--accent-rose);
    background: rgba(244, 63, 94, 0.1);
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(244, 63, 94, 0.2);
    animation: pulseWarning 2s infinite;
}

@keyframes pulseWarning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.hidden {
    display: none !important;
}

.safety-score {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

.score-bar-bg {
    width: 100px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-emerald), var(--accent-cyan));
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.score-text {
    font-family: var(--font-code);
    font-weight: 700;
    color: var(--accent-emerald);
}

/* Button Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-indigo));
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow-purple);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger-outline {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-rose);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger-outline:hover {
    background: rgba(244, 63, 94, 0.25);
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* Dictionary Preview Section */
.dictionary-preview-card {
    padding-bottom: 12px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.search-box input {
    padding: 7px 12px 7px 34px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
    width: 220px;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent-indigo);
    width: 260px;
}

.tags-container {
    padding: 20px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 180px;
    overflow-y: auto;
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    transition: var(--transition-fast);
}

.tag-item:hover {
    border-color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.1);
}

.tag-sensitive {
    color: #fca5a5;
    font-family: var(--font-code);
    font-weight: 500;
}

.tag-arrow {
    color: var(--text-muted);
    font-size: 10px;
}

.tag-safe {
    color: #6ee7b7;
    font-family: var(--font-code);
    font-weight: 600;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-content {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    overflow: hidden;
    background: #0f1426;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 140px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.add-rule-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-code);
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent-purple);
}

.dict-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.dict-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.dict-table th {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.dict-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.dict-table tr:last-child td {
    border-bottom: none;
}

.dict-table .sensitive-text {
    color: #fca5a5;
    font-family: var(--font-code);
}

.dict-table .safe-text {
    color: #6ee7b7;
    font-family: var(--font-code);
    font-weight: 500;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.success {
    border-left: 4px solid var(--accent-emerald);
}

.toast.success i {
    color: var(--accent-emerald);
}

.toast.info {
    border-left: 4px solid var(--accent-cyan);
}

.toast.info i {
    color: var(--accent-cyan);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: auto;
}

.text-pink {
    color: var(--accent-rose);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
