/* IT Site Survey AI - Dark Theme Styles */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #22d3ee;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --border-color: #334155;
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Tab Navigation */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-primary);
    padding: 0.25rem;
    border-radius: var(--border-radius);
}

.tab-btn {
    padding: 0.625rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 2rem;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

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

/* Surveys Grid */
.surveys-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* Survey Card */
.survey-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.survey-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.survey-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.analysis-badge {
    background: var(--success);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-weight: 500;
}

.survey-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.survey-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.survey-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.survey-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-delete-card {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-delete-card:hover {
    background: var(--danger);
    color: white;
}

/* Form Styles */
.survey-form {
    max-width: 900px;
}

.form-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.question-count {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-group label::after {
    content: '';
}

.form-group label[for]:has(+ [required])::after,
.form-group label:has(+ [required])::after {
    content: ' *';
    color: var(--danger);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-submit-section {
    text-align: center;
    padding: 2rem;
}

/* Questions Container */
.questions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

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

.question-number {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.question-category {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    color: var(--text-secondary);
}

.question-text {
    font-size: 0.9375rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.question-input input[type="text"],
.question-input select,
.question-input textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.question-input textarea {
    min-height: 80px;
    resize: vertical;
}

.question-input input:focus,
.question-input select:focus,
.question-input textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Photo Upload */
.photo-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.photo-upload-area:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.photo-upload-area.dragover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.photo-upload-area svg {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.photo-upload-area p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
}

/* Analysis Layout */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.btn-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analysis-controls {
    display: flex;
    gap: 0.75rem;
}

.model-select {
    padding: 0.625rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.analysis-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .analysis-layout {
        grid-template-columns: 1fr;
    }
}

/* Panel */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.panel h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

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

.panel-header h4 {
    margin-bottom: 0;
}

/* Survey Meta List */
.survey-meta-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* Question Summary */
.question-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: 6px;
    font-size: 0.875rem;
}

.question-summary-item .category {
    color: var(--text-secondary);
}

.question-summary-item .count {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Analysis Output */
.analysis-output-panel {
    min-height: 400px;
    display: flex;
    flex-direction: column;
}

.analysis-output {
    flex: 1;
    overflow-y: auto;
    max-height: 600px;
}

.analysis-placeholder {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
    padding: 3rem;
}

.analysis-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.analysis-content {
    line-height: 1.8;
    color: var(--text-primary);
}

.analysis-content h1,
.analysis-content h2,
.analysis-content h3,
.analysis-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.analysis-content h1 {
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.analysis-content h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.analysis-content h3 {
    font-size: 1.125rem;
    color: var(--accent-secondary);
}

.analysis-content p {
    margin-bottom: 0.75rem;
}

.analysis-content ul,
.analysis-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.analysis-content li {
    margin-bottom: 0.375rem;
}

.analysis-content strong {
    color: var(--accent-primary);
}

.analysis-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Analysis Loading */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Chat Panel */
.chat-panel {
    margin-top: 1rem;
}

.chat-messages {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.chat-message {
    padding: 0.875rem 1rem;
    border-radius: var(--border-radius);
    max-width: 85%;
}

.chat-message.system {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.875rem;
    align-self: center;
    text-align: center;
}

.chat-message.user {
    background: var(--accent-primary);
    color: white;
    align-self: flex-end;
}

.chat-message.assistant {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    align-self: flex-start;
}

.chat-message p {
    margin: 0;
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
}

.chat-input-area input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.chat-input-area input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.chat-input-area input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .app-main {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .surveys-grid {
        grid-template-columns: 1fr;
    }
    
    .analysis-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .analysis-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .analysis-controls {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-hover);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}
