/* CSS Custom Properties for Theming */
:root {
    /* Default theme colors - can be overridden via branding config */
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-secondary: #6b7280;
    --color-accent: #10b981;
    --color-background: #ffffff;
    --color-surface: #f9fafb;
    --color-text-primary: #1f2937;
    --color-text-secondary: #6b7280;
    --color-border: #e5e7eb;
    --color-error: #dc2626;
    --color-warning: #f59e0b;
    --color-success: #10b981;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Reset and base styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--color-text-primary);
    background-color: var(--color-surface);
}

/* Layout */
.main-content {
    min-height: calc(100vh - 120px);
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Navigation */
.navbar {
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    gap: var(--spacing-lg);
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--color-primary);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 150px;
    z-index: 1000;
    padding: 0.5rem 0;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--color-text-primary);
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--color-surface);
    color: var(--color-primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

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

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

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

.btn-secondary:hover {
    background: var(--color-text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}

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

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-danger:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

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

.btn-full {
    width: 100%;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.form-errors {
    margin-top: 0.5rem;
}

.form-error {
    display: block;
    color: #dc2626;
    font-size: 0.875rem;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Checkboxes and radios */
.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.checkbox-text {
    margin-left: 0.5rem;
}

/* Authentication */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #1f2937;
}

.auth-description {
    text-align: center;
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.auth-links {
    text-align: center;
    margin-top: 1.5rem;
}

.auth-links p {
    margin-bottom: 0.5rem;
}

.auth-links a {
    color: #2563eb;
    text-decoration: none;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Flash messages */
.flash-messages {
    margin-bottom: 2rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Dashboard */
.dashboard-header {
    text-align: center;
    margin-bottom: 3rem;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #1f2937;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2563eb;
    margin-bottom: 0.5rem;
}

.stat-label {
    color: #6b7280;
    font-weight: 500;
}

.dashboard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
}

/* Summaries */
.recent-summaries h2 {
    margin-bottom: 1.5rem;
    color: #1f2937;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
}

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

.summary-header h3 a {
    color: #1f2937;
    text-decoration: none;
    font-size: 1.125rem;
}

.summary-header h3 a:hover {
    color: #2563eb;
}

.summary-date {
    color: #6b7280;
    font-size: 0.875rem;
    white-space: nowrap;
}

.summary-meta {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.summary-author {
    margin-right: 1rem;
}

.summary-preview {
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.summary-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    background: #e0e7ff;
    color: #3730a3;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Summary actions */
.summary-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

.action-link {
    background: none;
    border: none;
    color: #2563eb;
    text-decoration: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.action-link:hover {
    background: #f3f4f6;
    color: #1d4ed8;
}

.action-link.delete-summary {
    color: #dc2626;
}

.action-link.delete-summary:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.action-link:disabled {
    color: #9ca3af;
    cursor: not-allowed;
    background: none;
}

/* API Key Management */
.api-key-section {
    margin-top: 1.5rem;
}

.api-key-display {
    margin-bottom: 1.5rem;
}

.api-key-value {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-key-input {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    background: #f8f9fa;
}

.api-key-input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.api-key-toggle {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.api-usage {
    margin-bottom: 1.5rem;
}

.usage-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.usage-progress {
    height: 100%;
    background: #10b981;
    transition: width 0.3s ease;
}

.usage-progress[style*="100%"] {
    background: #ef4444;
}

.api-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.api-docs-link {
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.api-docs-link a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.api-docs-link a:hover {
    text-decoration: underline;
}

/* API Documentation */
.api-docs {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.docs-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e5e7eb;
}

.docs-header h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #1f2937;
}

.docs-header p {
    font-size: 1.125rem;
    color: #6b7280;
}

.docs-section {
    margin-bottom: 3rem;
}

.docs-section h2 {
    font-size: 1.875rem;
    margin-bottom: 1rem;
    color: #1f2937;
    border-bottom: 2px solid #2563eb;
    padding-bottom: 0.5rem;
}

.docs-section h3 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem 0;
    color: #374151;
}

.docs-section h4 {
    font-size: 1.125rem;
    margin: 1.5rem 0 0.5rem 0;
    color: #4b5563;
}

.docs-section p {
    margin-bottom: 1rem;
    line-height: 1.6;
    color: #4b5563;
}

.docs-section ol, .docs-section ul {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.docs-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
    color: #4b5563;
}

.endpoint {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.endpoint-method {
    background: #2563eb;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 1rem;
}

.code-block {
    background: #1f2937;
    color: #f9fafb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.code-block h4 {
    color: #d1d5db;
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.code-block pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

.code-block code {
    color: #f9fafb;
    background: none;
    padding: 0;
    font-family: inherit;
}

/* Responsive */
@media (max-width: 768px) {
    .api-docs {
        padding: 1rem;
    }
    
    .docs-header h1 {
        font-size: 2rem;
    }
    
    .docs-section h2 {
        font-size: 1.5rem;
    }
    
    .endpoint {
        padding: 1rem;
    }
    
    .code-block {
        padding: 0.75rem;
    }
    
    .code-block pre {
        font-size: 0.75rem;
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state h2 {
    color: #6b7280;
    margin-bottom: 1rem;
}

.empty-state p {
    color: #9ca3af;
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background: #1f2937;
    color: #9ca3af;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-columns {
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.footer-columns .footer-section {
    float: left;
    width: 20%;
    min-width: 150px;
    text-align: left;
    padding-right: 1rem;
}

.footer-columns .footer-section h4 {
    color: #d1d5db;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.footer-columns .footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-links {
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.footer-links a {
    color: #9ca3af;
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #d1d5db;
    text-decoration: underline;
}

.footer-separator {
    margin: 0 1rem;
    color: #6b7280;
}

/* Responsive design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .dashboard-actions {
        flex-direction: column;
        align-items: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

/* Feedback Tab and Modal */
.feedback-tab {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: #3b82f6;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    user-select: none;
    min-width: 80px;
    text-align: center;
}

.feedback-tab:hover {
    background: #2563eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.feedback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.feedback-modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.feedback-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.feedback-modal-header h3 {
    margin: 0;
    color: var(--color-text-primary);
}

.feedback-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.feedback-close:hover {
    background: var(--color-surface);
    color: var(--color-text-primary);
}

.feedback-form {
    padding: 1.5rem;
}

.feedback-field {
    margin-bottom: 1.5rem;
}

.feedback-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
}

.feedback-field input,
.feedback-field select,
.feedback-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.feedback-field input:focus,
.feedback-field select:focus,
.feedback-field textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.feedback-field textarea {
    resize: vertical;
    min-height: 100px;
}

.feedback-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

.feedback-actions .btn-secondary {
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.feedback-actions .btn-secondary:hover {
    background: var(--color-surface);
    border-color: var(--color-text-secondary);
}

.feedback-actions .btn-primary {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.feedback-actions .btn-primary:hover {
    background: var(--color-primary-hover);
}

.feedback-actions .btn-primary:disabled {
    background: var(--color-secondary);
    cursor: not-allowed;
}

.feedback-success {
    padding: 1.5rem;
    text-align: center;
}

.feedback-success h4 {
    color: var(--color-success);
    margin-bottom: 1rem;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Survey Questions */
.survey-question {
    font-weight: bold !important;
}

.question-block {
    margin-top: 1.5rem !important;
}

.question-block:first-child {
    margin-top: 0 !important;
}

/* Tailwind-like utilities for survey template */
.space-y-8 > * + * {
    margin-top: 2rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-gray-800 {
    color: #1f2937;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.block {
    display: block;
}

.w-full {
    width: 100%;
}

/* Add padding only to input elements, not buttons or other w-full elements */
input.w-full, textarea.w-full, select.w-full {
    padding: 5px;
}

/* Responsive feedback modal */
@media (max-width: 768px) {
    .feedback-tab {
        right: 10px;
        font-size: 12px;
        padding: 10px 16px;
    }
    
    .feedback-modal-content {
        width: 95%;
        margin: 1rem;
    }
    
    .feedback-modal-header,
    .feedback-form {
        padding: 1rem;
    }
    
    .feedback-actions {
        flex-direction: column;
    }
}