:root {
    --bg-color: #0f1115;
    --panel-bg: rgba(25, 28, 36, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --success: #10b981;
    --error: #ef4444;
    --ad-badge: #f59e0b;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.background-mesh {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
    height: 100vh;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
.sidebar {
    width: 280px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: calc(100vh - 4rem);
}

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

.logo-icon {
    font-size: 1.5rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 1rem;
    border-radius: 12px;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-btn.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border-right: 3px solid var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-right: 1rem;
}

.module-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.module-section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.section-header p {
    color: var(--text-muted);
}

/* Forms */
.form-panel {
    padding: 2rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-row {
    display: flex;
    gap: 1.5rem;
}

.input-row > .input-group {
    flex: 1;
}

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

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

input, select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}

select {
    background-color: var(--bg-color); /* Solid background works better for native selects */
    cursor: pointer;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

select option {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.primary-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.primary-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Results Container */
.results-container {
    padding: 2rem;
    margin-top: auto;
}

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

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-main);
}

.hidden {
    display: none !important;
}

/* Loader */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 0;
}

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

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
}
.status-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-error { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.ad-badge { background: rgba(245, 158, 11, 0.2); color: var(--ad-badge); border: 1px solid rgba(245, 158, 11, 0.5); }

/* --- Visual Data Cards --- */

/* Rating Card (Mod 1) */
.rating-card {
    display: flex;
    align-items: center;
    gap: 2rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 2rem;
}
.rating-value {
    font-size: 3rem;
    font-weight: 700;
    color: #fbbf24;
}
.rating-info h3 {
    margin-bottom: 0.5rem;
}
.rating-info p {
    color: var(--text-muted);
}

/* Reviews Grid (Mod 2) */
.reviews-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.review-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}
.review-rating {
    color: #fbbf24;
    font-weight: 700;
}
.review-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.review-text {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-main);
}
.review-type-pos { border-left: 3px solid var(--success); }
.review-type-neg { border-left: 3px solid var(--error); }

/* Competitor Card (Mod 3) */
.competitor-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
.competitor-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1.5rem;
}
.comp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.comp-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.comp-title h3 {
    font-size: 1.25rem;
}
.comp-title a {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
}
.comp-stats {
    display: flex;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.comp-reviews-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}
.review-col h4 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}
@media(max-width: 768px) {
    .comp-reviews-section {
        grid-template-columns: 1fr;
    }
}

/* Projects Module */
.projects-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.projects-sidebar {
    padding: 1.5rem;
}

.projects-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
}

.projects-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.project-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.project-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.project-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-left: 3px solid var(--accent);
}

.project-details {
    padding: 2rem;
}

.project-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
}

.project-header h2 {
    flex: 1;
}

.project-links h3 {
    margin-bottom: 1rem;
}

.add-link-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.links-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
}

.link-item a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
    margin-right: 1rem;
}

.btn-remove-link {
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.25rem;
}

/* Project Scan Results */
.scan-result-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.scan-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.scan-result-url {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.scan-result-stats {
    display: flex;
    gap: 1.5rem;
    font-size: 1.1rem;
}

.scan-result-reviews h4 {
    margin: 1rem 0 0.5rem 0;
    color: var(--text-muted);
}

/* --- Responsive Design (Mobile / Tablets) --- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding: 1rem;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }

    .nav-menu {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .nav-menu::-webkit-scrollbar {
        height: 4px;
    }
    .nav-menu::-webkit-scrollbar-thumb {
        background: var(--panel-border);
        border-radius: 4px;
    }

    .nav-btn {
        white-space: nowrap;
        padding: 0.5rem 1rem;
    }

    .main-content {
        height: auto;
        overflow-y: visible;
        padding-right: 0;
    }

    .projects-container {
        grid-template-columns: 1fr;
    }

    .input-row {
        flex-direction: column;
        gap: 1.5rem;
    }

    .form-panel, .project-details, .results-container {
        padding: 1.25rem;
    }

    .rating-card {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.5rem;
    }

    .project-header, .scan-result-header, .add-link-form {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .link-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .section-header h1 {
        font-size: 1.5rem;
    }
}
