:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --accent: #22d3ee;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-white: #f8fafc;
    --text-dim: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    scrollbar-gutter: stable;
    /* Prevents layout shift when scrollbar appears */
}

h1,
h2,
h3,
.logo-text {
    font-family: 'Outfit', sans-serif;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.5;
}

.blob {
    position: absolute;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
}

.blob-1 {
    background: radial-gradient(circle, #6366f1, transparent);
    top: -10%;
    left: -10%;
    animation: move-1 20s infinite alternate;
}

.blob-2 {
    background: radial-gradient(circle, #ec4899, transparent);
    bottom: -10%;
    right: -10%;
    animation: move-2 25s infinite alternate;
}

.blob-3 {
    background: radial-gradient(circle, #0ea5e9, transparent);
    top: 30%;
    left: 40%;
    animation: move-3 30s infinite alternate;
}

@keyframes move-1 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(100px, 100px);
    }
}

@keyframes move-2 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(-100px, -50px);
    }
}

@keyframes move-3 {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(50px, -100px);
    }
}

/* Navigation */
.glass-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
}

.nav-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.accent {
    color: var(--accent);
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-config-labels {
    display: flex;
    gap: 0.5rem;
}

.nav-separator {
    width: 1px;
    height: 1.5rem;
    background: var(--glass-border);
    margin: 0 0.5rem;
}

.nav-link {
    background: none;
    border: none;
    color: var(--text-dim);
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.1);
}

/* Container */
.container {
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 2rem;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

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

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

/* Hero Section */
.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(90deg, #6366f1, #22d3ee);
    -webkit-background-clip: text;
    background-clip: text;
    /* Added standard property for compatibility */
    -webkit-text-fill-color: transparent;
}

.hero p {
    color: var(--text-dim);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.active-config-hint {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Glass Card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    min-height: 3rem;
    /* Stabilize header height */
}

/* Upload Area */
.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.highlight {
    color: var(--primary);
    font-weight: 600;
}

.file-info {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.search-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-option {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.search-option:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.option-icon {
    font-size: 1.25rem;
}

.option-text {
    display: flex;
    flex-direction: column;
}

.option-label {
    font-weight: 600;
    color: var(--text-white);
    font-size: 0.9rem;
}

.option-desc {
    color: var(--text-dim);
    font-size: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.8rem 2rem;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-primary:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

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

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

.btn-sm {
    padding: 0.5rem 1rem;
    width: auto;
    font-size: 0.875rem;
}

/* Loading */
.loading-area {
    text-align: center;
    margin-top: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Results */
.result-area {
    margin-top: 3rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-dim);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-value.true {
    color: var(--success);
}

.stat-value.false {
    color: var(--error);
}

.tone-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.tone-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.json-preview-container {
    margin-top: 2rem;
}

pre#json-preview {
    padding: 1.5rem;
    border-radius: 12px;
    font-size: 0.875rem;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    transition: opacity 0.3s ease, margin 0.3s ease, transform 0.3s ease;
}

.form-group.hidden {
    opacity: 0;
    margin: 0;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    display: block !important;
    /* Override the previous utility for animation support */
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.glass-input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    display: block;
    /* Ensure it stays full width */
}

select.glass-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.5em;
    padding-right: 3rem;
}

select.glass-input option {
    background-color: #1e293b;
    color: white;
}

.glass-input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.toast {
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease forwards;
}

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

.toast.error {
    border-left: 4px solid var(--error);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

.hidden {
    display: none !important;
}

.badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(34, 211, 238, 0.2);
}

/* Rules Page */
.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

/* Rules Listing View */
.rules-table {
    padding: 0;
    overflow: hidden;
    border-collapse: separate;
}

.table-header {
    display: flex;
    justify-content: space-between;
    padding: 1.25rem 2rem;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    font-weight: 600;
    color: var(--accent);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.3s ease;
}

.table-row:last-child {
    border-bottom: none;
}

.table-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.rule-preview {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex: 1;
    margin-right: 2rem;
}

.rule-index {
    color: var(--accent);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    min-width: 25px;
}

.rule-preview p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-white);
    line-height: 1.5;
}

.rule-control {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-shrink: 0;
}

.rule-edit-btn,
.rule-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.rule-edit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.rule-delete-btn:hover {
    background: rgba(255, 77, 77, 0.1);
    transform: scale(1.1);
}

.disabled-opacity {
    opacity: 0.4;
    filter: grayscale(0.5);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #22d3ee;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

textarea.glass-input {
    resize: vertical;
    line-height: 1.5;
}

/* Rules Feedback in Results */
.rules-feedback-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.rules-feedback-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.rule-feedback-item {
    padding: 1.25rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.02);
}

.rule-feedback-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rule-text-feedback {
    font-weight: 600;
    color: var(--text-white);
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    text-transform: uppercase;
}

.status-followed {
    background: rgba(34, 211, 238, 0.2);
    color: #22d3ee;
    border: 1px solid rgba(34, 211, 238, 0.3);
}

.status-not-followed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.rule-explanation {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.4;
    font-style: italic;
}

/* Mistakes Section */
.mistakes-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.mistakes-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.mistake-item {
    padding: 1.25rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    border-left: 4px solid;
    background: rgba(255, 255, 255, 0.02);
}

.mistake-item.severity-low {
    border-left-color: #fbbf24;
    background: rgba(251, 191, 36, 0.05);
}

.mistake-item.severity-medium {
    border-left-color: #f97316;
    background: rgba(249, 115, 22, 0.05);
}

.mistake-item.severity-high {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.mistake-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.mistake-text {
    font-weight: 600;
    color: var(--text-white);
    flex: 1;
}

.severity-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    text-transform: uppercase;
    white-space: nowrap;
}

.severity-badge.low {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.severity-badge.medium {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.severity-badge.high {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.mistake-explanation {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.correct-info {
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid #22c55e;
    border-radius: 6px;
    color: #22c55e;
    font-weight: 500;
    font-size: 0.9rem;
    margin: 0.5rem 0;
}

/* Web Search Indicator */
.web-search-badge {
    margin-top: 1rem;
    padding: 0.75rem 1.25rem;
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.3);
    border-radius: 12px;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

.web-search-badge span {
    color: #22d3ee;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Report Sections */
.report-section {
    margin-top: 2rem;
    padding: 2rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
}

.report-section h3 {
    color: var(--accent);
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.section-content {
    color: var(--text-white);
}

.sub-section {
    margin-bottom: 1.5rem;
}

.sub-section h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sub-section p {
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.6;
}

.bullet-list {
    list-style: none;
    padding: 0;
}

.bullet-list li {
    position: relative;
    padding-left: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-dim);
    font-size: 0.95rem;
    line-height: 1.5;
}

.bullet-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* Report Table */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.report-table th {
    background: rgba(255, 255, 255, 0.05);
    text-align: left;
    padding: 1rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
}

.report-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-dim);
    vertical-align: top;
    line-height: 1.5;
}

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

.report-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.glass-inner {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    color: var(--text-dim);
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Cache Stats */
.cache-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Login Page Styles */
#login-page {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

#login-page.active {
    display: flex;
}

.login-container {
    max-width: 450px;
    width: 100%;
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-header h2 {
    font-size: 2.25rem;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.login-header p {
    color: var(--text-dim);
    font-size: 0.95rem;
}

.login-btn {
    margin-top: 1rem;
    font-size: 1rem;
    padding: 0.9rem;
}

.logout-btn {
    color: var(--error) !important;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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