/**
 * Surveys CSS
 * Styles for Universal Survey Platform
 */

/* ============================================
   MODAL SYSTEM - CRITICAL FIX
   ============================================ */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px);
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative !important;
}

/* Surveys Page */
.surveys-page {
    padding: 20px;
}

.surveys-header h1 {
    margin: 0;
    font-size: 28px;
    color: #1f2937;
}

/* Sub-tabs */
.surveys-subtabs {
    display: flex;
    gap: 8px;
    margin: 24px 0;
    border-bottom: 2px solid #e2e8f0;
}

.subtab-btn {
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.subtab-btn:hover {
    color: #1f2937;
    background: #f8fafc;
}

.subtab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.subtab-content {
    display: none;
    padding: 24px 0;
}

.subtab-content.active {
    display: block;
}

/* Surveys List */
.surveys-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.surveys-filters {
    display: flex;
    gap: 12px;
}

.surveys-filters select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.surveys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Survey Card */
.survey-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.survey-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.survey-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.survey-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: #f1f5f9;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
}

.survey-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
}

.survey-card-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #1f2937;
}

.survey-card-description {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 16px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.survey-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.survey-card-progress {
    margin-bottom: 16px;
}

.progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.survey-card-actions {
    display: flex;
    gap: 8px;
}

/* Survey Creator */
.survey-creator {
    max-width: 800px;
    margin: 0 auto;
}

.survey-creator h2 {
    margin: 0 0 24px 0;
    font-size: 24px;
    color: #1f2937;
}

.creator-step {
    margin-bottom: 32px;
}

.creator-step.hidden {
    display: none;
}

.creator-step h3 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #1f2937;
}

.survey-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.survey-type-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.survey-type-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.type-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.survey-type-card h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #1f2937;
}

.survey-type-card p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Questions Editor */
#questions-container {
    margin-bottom: 20px;
}

.question-editor {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.question-number {
    font-weight: 600;
    color: #667eea;
    font-size: 14px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f1f5f9;
}

/* Respondents Selection */
.respondents-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: #1f2937;
}

.users-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 12px;
    background: #f9fafb;
}

.user-checkbox {
    display: block;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.user-checkbox:hover {
    background: #f1f5f9;
}

.user-checkbox input {
    margin-right: 8px;
}

/* Survey Taker */
.survey-progress {
    margin-bottom: 32px;
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 14px;
    color: #64748b;
}

.survey-question {
    margin-bottom: 32px;
}

.survey-question h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #1f2937;
}

.scale-input {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.scale-option {
    flex: 1;
    min-width: 60px;
    text-align: center;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.scale-option:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.scale-option.selected {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

.scale-option input {
    display: none;
}

.choice-input {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-option {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.choice-option:hover {
    border-color: #667eea;
    background: #f8fafc;
}

.choice-option input {
    margin-right: 12px;
}

.survey-navigation {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 32px;
}

/* Results View */
.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    color: white;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    color: white;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.9;
    color: white;
}

.results-questions {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.question-result {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.question-result h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #1f2937;
}

/* Scale Results */
.scale-result {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 24px;
    align-items: center;
}

.scale-avg {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.avg-value {
    display: block;
    font-size: 48px;
    font-weight: 700;
}

.avg-label {
    display: block;
    font-size: 13px;
    margin-top: 8px;
    opacity: 0.9;
}

.scale-distribution {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scale-bar {
    display: grid;
    grid-template-columns: 30px 1fr 50px;
    gap: 12px;
    align-items: center;
}

.scale-label {
    font-weight: 600;
    color: #64748b;
}

.scale-bar-bg {
    height: 24px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.scale-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.scale-count {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    text-align: right;
}

/* Text Responses */
.text-responses {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.text-response {
    padding: 12px 16px;
    background: #f8fafc;
    border-left: 3px solid #667eea;
    border-radius: 4px;
    font-style: italic;
    color: #475569;
}

/* Choice Results */
.choice-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-bar {
    display: grid;
    grid-template-columns: 200px 1fr 100px;
    gap: 12px;
    align-items: center;
}

.choice-label {
    font-weight: 500;
    color: #1f2937;
}

.choice-bar-bg {
    height: 32px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
}

.choice-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.choice-count {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    text-align: right;
}

/* AI Analysis */
.ai-analysis-content {
    line-height: 1.8;
    color: #374151;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 15px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    color: #1f2937;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #f8fafc;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.hidden {
    display: none !important;
}

/* Modal Enhancements */
.modal-content.large {
    max-width: 900px;
    width: 90%;
}

.public-link-box {
    margin: 16px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .surveys-grid {
        grid-template-columns: 1fr;
    }

    .survey-types-grid {
        grid-template-columns: 1fr;
    }

    .scale-result {
        grid-template-columns: 1fr;
    }

    .choice-bar {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .choice-label {
        margin-bottom: 4px;
    }
}
