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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Fixed Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sidebar-header p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.classification-categories h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.classification-categories ul {
    list-style: none;
}

.categories-description {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.categories-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.categories-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.link-icon {
    font-size: 1rem;
}

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

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: white;
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Ensure proper spacing for anchor targets */
h2[id] {
    scroll-margin-top: 2rem;
}

.category-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.category-dot.communication { background-color: #3b82f6; }
.category-dot.information { background-color: #10b981; }
.category-dot.decision { background-color: #f59e0b; }
.category-dot.action { background-color: #ef4444; }
.category-dot.announcement { background-color: #8b5cf6; }
.category-dot.crisis { background-color: #dc2626; }
.category-dot.relationship { background-color: #06b6d4; }

.llm-settings {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.llm-settings h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.provider-selector {
    margin-bottom: 1rem;
}

.provider-selector label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.provider-selector select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
    font-size: 0.85rem;
}

.provider-selector select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.8);
    background: white;
}

.api-key-section {
    margin-top: 1rem;
}

.api-key-section label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.api-key-section input,
.api-key-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 60px;
}

.api-key-textarea {
    height: 80px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.api-key-section input::placeholder,
.api-key-textarea::placeholder {
    color: #64748b;
}

.api-key-section input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.8);
    background: white;
}

.save-key-btn {
    width: 100%;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.save-key-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.save-key-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.save-key-btn:disabled:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* API Key Modal Button */
.api-key-modal-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.api-key-modal-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.key-icon {
    font-size: 1rem;
}

/* Modal Styles */
.modal-overlay {
    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: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #374151;
}

.modal-body {
    padding: 2rem;
}

.api-key-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.api-key-form label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.api-key-textarea-modal {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    min-height: 120px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.api-key-textarea-modal:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.api-key-info {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    font-size: 0.85rem;
    color: #64748b;
}

.api-key-info p {
    margin: 0.25rem 0;
    font-weight: 500;
}

.api-key-info strong {
    color: #374151;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding: 1.5rem 2rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

.cancel-btn {
    padding: 0.75rem 1.5rem;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: #e2e8f0;
    color: #374151;
}

.save-key-btn-modal {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.save-key-btn-modal:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.save-key-btn-modal:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.save-key-btn-modal:disabled:hover {
    transform: none;
    box-shadow: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 2rem;
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 1rem;
}

.content-wrapper {
    width: 100%;
    height: 100vh;
    transition: all 0.3s ease;
}

/* Initial state - only input, full width */
.content-wrapper.initial-state {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem;
}

.content-wrapper.initial-state .output-column {
    display: none !important;
}

/* After generation - minimized input, full width results */
.content-wrapper.generated-state {
    display: flex !important;
    flex-direction: column !important;
    gap: 1rem;
}

.content-wrapper.generated-state .output-column {
    display: block !important;
}

/* Minimized input bar */
.input-column.minimized {
    height: 60px !important;
    overflow: hidden;
    transition: height 0.3s ease;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    position: relative;
    flex-shrink: 0;
}

.input-column.minimized .input-container {
    height: 100%;
    padding: 0.5rem;
}

.input-column.minimized #emailInput {
    height: 40px;
    font-size: 0.9rem;
    resize: none;
    overflow: hidden;
}

.input-column.minimized .input-actions {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-column.minimized .generate-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

/* Expand button for minimized input */
.expand-btn {
    background: #6366f1;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.expand-btn:hover {
    background: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.expand-icon {
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.expand-btn:hover .expand-icon {
    transform: translateY(1px);
}

/* Full width results */
.output-column.full-width {
    width: 100% !important;
    height: calc(100vh - 80px) !important;
    margin-top: 1rem;
    flex: 1;
}

/* Input Column */
.input-column {
    display: flex;
    flex-direction: column;
}

/* Full width input in initial state */
.content-wrapper.initial-state .input-column {
    width: 100% !important;
    height: 100vh !important;
}

.input-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e293b;
}

.input-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#emailInput {
    width: 100%;
    flex: 1;
    min-height: 300px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

#emailInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

.classify-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.classify-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.classify-button:active {
    transform: translateY(0);
}

.button-icon {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.classify-button:hover .button-icon {
    transform: translateX(2px);
}

.clear-button {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-button:hover {
    background: #e2e8f0;
}

/* Output Column */
.output-column {
    display: flex;
    flex-direction: column;
}

.output-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e293b;
}

.results-container {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    height: 100%;
    overflow-y: auto;
}

.placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #64748b;
    text-align: center;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Results Styling */
.template-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
}

.template-section, .analysis-section, .suggestions-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
}

.email-template {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-x: auto;
}

.template-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.copy-button, .edit-button {
    padding: 0.5rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-button:hover {
    background: #f0f9ff;
    border-color: #0ea5e9;
    color: #0ea5e9;
}

.edit-button:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #f59e0b;
}

.analysis-item {
    margin-bottom: 1rem;
}

.analysis-item strong {
    color: #374151;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.analysis-item p {
    color: #6b7280;
    margin: 0;
}

.analysis-item ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.5rem;
}

.analysis-item li {
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.guidance-section, .suggestions-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guidance-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.guidance-item {
    border-left: 3px solid #667eea;
    padding-left: 1rem;
}

.guidance-item strong {
    color: #374151;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.guidance-item p {
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.suggestions-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.suggestion-group {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    border: 1px solid #e5e7eb;
}

.suggestion-group h4 {
    color: #374151;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.suggestion-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.suggestion-group li {
    color: #6b7280;
    padding: 0.25rem 0;
    position: relative;
    padding-left: 1rem;
}

.suggestion-group li:before {
    content: "•";
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.suggestion-group p {
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.classification-info {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
}

.classification-info details {
    cursor: pointer;
}

.classification-info summary {
    font-weight: 600;
    color: #64748b;
    font-size: 0.9rem;
}

.tech-details {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e2e8f0;
}

.tech-details p {
    margin: 0.25rem 0;
    font-size: 0.85rem;
    color: #64748b;
}

.result-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.category-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.75rem;
}

.category-badge.communication { background: #dbeafe; color: #1e40af; }
.category-badge.information { background: #d1fae5; color: #065f46; }
.category-badge.decision { background: #fef3c7; color: #92400e; }
.category-badge.action { background: #fee2e2; color: #991b1b; }
.category-badge.announcement { background: #e9d5ff; color: #6b21a8; }
.category-badge.crisis { background: #fecaca; color: #7f1d1d; }
.category-badge.relationship { background: #cffafe; color: #155e75; }

.sub-type {
    font-weight: 600;
    color: #1e293b;
}

.result-content {
    margin-top: 0.75rem;
}

.result-field {
    margin-bottom: 0.75rem;
}

.result-field strong {
    color: #374151;
    font-weight: 600;
    display: block;
    margin-bottom: 0.25rem;
}

.result-field p {
    color: #6b7280;
    margin: 0;
    padding-left: 0.5rem;
}

.action-items {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 6px;
    padding: 0.75rem;
    margin-top: 0.75rem;
}

.action-items h4 {
    color: #92400e;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.action-item {
    background: white;
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.action-item:last-child {
    margin-bottom: 0;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    color: #667eea;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sidebar {
        width: 250px;
    }
    
    .main-content {
        margin-left: 250px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .content-wrapper {
        gap: 1rem;
    }
}
