/* CSS Variables for Sheepified Color Palette */
:root {
    --davys-gray: #53544Eff;
    --jet: #2C302Cff;
    --eerie-black: #212624ff;
    --pale-dogwood: #E9BBAAff;
    --dun: #C3BCAEff;
    --coral-pink: #E79D8Fff;
}

/* Connection notification */
.connection-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: none;
}

.connection-notification.success {
    background-color: #10b981;
}

.connection-notification.error {
    background-color: #ef4444;
}

.connection-notification.warning {
    background-color: #f59e0b;
}

/* Light Mode Colors */
[data-theme="light"] {
    --bg-primary: var(--pale-dogwood);
    --bg-secondary: white;
    --bg-gradient: linear-gradient(135deg, var(--pale-dogwood) 0%, white 50%, var(--dun) 100%);
    --text-primary: var(--eerie-black);
    --text-secondary: var(--davys-gray);
    --text-hover: var(--eerie-black);
    --header-text: var(--eerie-black);
    --header-subtext: var(--davys-gray);
    --card-bg: white;
    --border-color: var(--dun);
    --shadow-color: rgba(33, 38, 36, 0.1);
    --ad-bg: white;
    --ad-border: var(--dun);
    --ad-text: var(--davys-gray);
}

/* Dark Mode Colors */
[data-theme="dark"] {
    --bg-primary: var(--eerie-black);
    --bg-secondary: var(--jet);
    --bg-gradient: linear-gradient(135deg, var(--eerie-black) 0%, var(--jet) 50%, var(--davys-gray) 100%);
    --text-primary: var(--eerie-black);
    --text-secondary: var(--davys-gray);
    --text-hover: #1a1816;
    --header-text: var(--pale-dogwood);
    --header-subtext: var(--dun);
    --card-bg: var(--pale-dogwood);
    --border-color: var(--dun);
    --shadow-color: rgba(33, 38, 36, 0.2);
    --ad-bg: var(--jet);
    --ad-border: var(--davys-gray);
    --ad-text: var(--dun);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1000;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--shadow-color);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--text-primary);
    transition: fill 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Layout Structure */
.main-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    padding: 2rem 0;
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    padding-top: 4rem; /* Extra space for theme toggle */
    width: 100%;
}

/* Ad Sidebar Styles */
.ad-sidebar {
    position: fixed;
    top: 0;
    width: 300px;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    z-index: 100;
}

.ad-sidebar.ad-left {
    left: 0;
}

.ad-sidebar.ad-right {
    right: 0;
}

.ad-placeholder {
    background: var(--ad-bg);
    border: 2px dashed var(--ad-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    width: 100%;
    max-width: 280px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.ad-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ad-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.ad-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ad-banner {
    background: linear-gradient(135deg, var(--coral-pink), var(--pale-dogwood));
    color: var(--eerie-black);
    padding: 2rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.ad-content p {
    font-size: 0.9rem;
    color: var(--ad-text);
    opacity: 0.8;
}



/* Header Styles */
header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--header-text);
    margin: 0;
    transition: color 0.3s ease;
}

.tagline {
    color: var(--header-subtext);
    font-size: 1.1rem;
    font-weight: 300;
    transition: color 0.3s ease;
}

/* Tab Navigation */
.tabs {
    display: flex;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--coral-pink);
    color: var(--eerie-black);
    box-shadow: 0 2px 8px rgba(231, 157, 143, 0.3);
}

.tab-btn:hover:not(.active) {
    background: rgba(231, 157, 143, 0.2);
    color: var(--text-primary);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Card Styles */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px var(--shadow-color);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.card h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    transition: color 0.3s ease;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown select {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: white;
    color: var(--jet);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 1;
}

.custom-dropdown select:focus {
    outline: none;
    border-color: var(--coral-pink);
    box-shadow: 0 0 0 3px rgba(231, 157, 143, 0.1);
}

.custom-dropdown select:hover {
    border-color: var(--coral-pink);
    box-shadow: 0 2px 8px rgba(231, 157, 143, 0.2);
}

/* Custom dropdown arrow */
.custom-dropdown::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--davys-gray);
    pointer-events: none;
    transition: transform 0.3s ease, border-top-color 0.3s ease;
    z-index: 2;
}

.custom-dropdown select:focus + .custom-dropdown::after,
.custom-dropdown:hover::after {
    border-top-color: var(--coral-pink);
    transform: translateY(-50%) rotate(180deg);
}

/* Dark mode adjustments */
[data-theme="dark"] .custom-dropdown select {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .custom-dropdown select:focus {
    border-color: var(--coral-pink);
    box-shadow: 0 0 0 3px rgba(231, 157, 143, 0.2);
}

[data-theme="dark"] .custom-dropdown::after {
    border-top-color: var(--text-secondary);
}

[data-theme="dark"] .custom-dropdown select:focus + .custom-dropdown::after,
[data-theme="dark"] .custom-dropdown:hover::after {
    border-top-color: var(--coral-pink);
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
    background: white;
    color: var(--jet);
}

textarea:focus {
    outline: none;
    border-color: var(--coral-pink);
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--coral-pink);
    color: var(--eerie-black);
    box-shadow: 0 2px 8px rgba(231, 157, 143, 0.3);
}

.btn-primary:hover {
    background: #d88a7a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 157, 143, 0.4);
}

/* Answer Button Styles */
.btn-answer {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    margin: 0.25rem;
    min-width: 120px;
}

.btn-answer:hover {
    background: var(--coral-pink);
    color: var(--text-hover);
    border-color: var(--coral-pink);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* Answer Badge Styles */
.answer-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.answer-badge.strongly-agree {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.answer-badge.agree {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.answer-badge.neutral {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: white;
}

.answer-badge.disagree {
    background: linear-gradient(135deg, #f87171, #ef4444);
    color: white;
}

.answer-badge.strongly-disagree {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

/* Consensus Bar Colors */
.strongly-agree-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.agree-fill {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.neutral-fill {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.disagree-fill {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.strongly-disagree-fill {
    background: linear-gradient(90deg, #dc2626, #b91c1c);
}

/* Result Styles */
.result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    border-left: 4px solid var(--coral-pink);
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.result.hidden {
    display: none;
}

.alignment-meter {
    width: 100%;
    height: 12px;
    background: var(--dun);
    border-radius: 6px;
    overflow: hidden;
    margin: 1rem 0;
}

.meter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--coral-pink), var(--pale-dogwood), var(--dun));
    transition: width 1s ease;
    border-radius: 6px;
}

/* Answer Buttons */
.answer-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
}

/* Comparison Styles */
.comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 1.5rem 0;
}

.your-answer, .community-answer {
    text-align: center;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.answer-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.answer-badge.agree {
    background: #d4edda;
    color: #155724;
}

.answer-badge.neutral {
    background: #fff3cd;
    color: #856404;
}

.answer-badge.disagree {
    background: #f8d7da;
    color: #721c24;
}

/* Score Display */
.score-display {
    text-align: center;
    margin: 2rem 0;
}

.score-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: conic-gradient(var(--coral-pink) 0deg, var(--coral-pink) 0deg, var(--dun) 0deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    width: 160px;
    height: 160px;
    background: var(--card-bg);
    border-radius: 50%;
    transition: background 0.3s ease;
}

.score-number {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    z-index: 1;
    transition: color 0.3s ease;
}

.score-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    z-index: 1;
    transition: color 0.3s ease;
}

/* Score Breakdown */
.score-breakdown {
    margin: 2rem 0;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.breakdown-item:last-child {
    border-bottom: none;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

/* End Message */
.end-message {
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* Next Question Button Container */
#next-question-container {
    margin-top: 2rem;
    text-align: center;
}

#next-question-container .btn {
    min-width: 150px;
}

/* Question Progress */
.question-progress {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 1rem;
    transition: color 0.3s ease;
}

/* Character Count */
.char-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: 0.25rem;
}

/* Loading States */
.btn-loading {
    display: none;
}

.btn-loading.hidden {
    display: none;
}

.btn:disabled .btn-text {
    display: none;
}

.btn:disabled .btn-loading {
    display: inline;
}

/* Category Selection */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.category-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-checkbox:hover {
    border-color: var(--coral-pink);
    background: rgba(231, 157, 143, 0.1);
}

.category-checkbox input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--coral-pink);
}

.category-checkbox input[type="checkbox"]:checked + label {
    color: var(--coral-pink);
    font-weight: 600;
}

/* Consensus Breakdown */
.consensus-breakdown {
    margin: 1.5rem 0;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.consensus-bars {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

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

.consensus-bar span:first-child {
    width: 120px;
    font-weight: 500;
    flex-shrink: 0;
}

.bar-container {
    flex: 1;
    height: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.agree-fill {
    background: linear-gradient(90deg, #4ade80, #22c55e);
}

.neutral-fill {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.disagree-fill {
    background: linear-gradient(90deg, #f87171, #ef4444);
}

.consensus-bar span:last-child {
    width: 80px;
    text-align: right;
    font-weight: 600;
    flex-shrink: 0;
}

/* Error Messages */
.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.error h3 {
    color: #ef4444;
    margin: 0 0 0.5rem 0;
}

.error p {
    color: var(--text-secondary);
    margin: 0;
}

/* Success Messages */
.result {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.result h3 {
    color: #22c55e;
    margin: 0 0 0.5rem 0;
}

.result p {
    color: var(--text-secondary);
    margin: 0;
}

/* Total Responses Display */
.total-responses {
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .ad-sidebar {
        display: none;
    }
    
    .main-wrapper {
        margin: 0;
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        min-height: 100vh;
        padding: 1rem 0;
    }
    
    .container {
        padding: 1rem;
        padding-top: 3rem;
    }
    
    .theme-toggle {
        top: 0.5rem;
        left: 0.5rem;
        width: 40px;
        height: 40px;
    }
    
    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .answer-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-answer {
        min-width: 100%;
        margin: 0.125rem 0;
    }
    
    .comparison {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .score-circle {
        width: 150px;
        height: 150px;
    }
    
    .score-circle::before {
        width: 120px;
        height: 120px;
    }
    
    .score-number {
        font-size: 2rem;
    }
    
    .ad-bottom {
        height: 60px; /* Even smaller on mobile */
        padding: 0 0.5rem;
    }
    
    .ad-bottom .ad-placeholder {
        height: 50px;
    }
    
    .ad-bottom .ad-content {
        font-size: 0.7rem;
    }
    
    .ad-bottom .ad-banner {
        font-size: 0.8rem;
        margin-bottom: 1px;
    }
    
    .ad-bottom p {
        font-size: 0.6rem;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .consensus-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .consensus-bar span:first-child {
        width: auto;
        font-size: 0.8rem;
    }
    
    .bar-container {
        width: 100%;
    }
    
    .consensus-bar span:last-child {
        width: auto;
        text-align: left;
        font-size: 0.8rem;
    }
} 