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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.logo i {
    font-size: 2rem;
    color: #ffd700;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ffd700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Tab Navigation */
.main-tab-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tab-navigation {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0 1rem;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    color: #6c757d;
    font-weight: 500;
}

.tab-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: white;
}

.tab-btn i {
    margin-right: 0.5rem;
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex !important;
    flex-direction: column;
}

/* Tone Guidelines Area */
.tone-guidelines-area {
    padding: 2rem;
    background: white;
    border-radius: 10px;
    margin: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.tone-guidelines-area h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: #495057;
    font-size: 1.3rem;
}

.tone-guidelines-area h3 i {
    color: #667eea;
}

.tone-guidelines-area textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s ease;
}

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

.tone-guidelines-area .btn {
    margin-top: 1rem;
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    overflow-y: auto;
    padding: 1rem;
}

.section {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: #495057;
    font-size: 1.1rem;
}

.section h3 i {
    color: #667eea;
}

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

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.send-btn {
    padding: 0.75rem;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    justify-content: center;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.file-upload-area:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.file-upload-area i {
    font-size: 3rem;
    color: #6c757d;
    margin-bottom: 1rem;
}

.file-upload-area p {
    color: #6c757d;
    margin: 0;
}

.uploaded-files {
    margin-top: 1rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #e9ecef;
    border-radius: 5px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.file-item .file-name {
    flex: 1;
    margin-right: 0.5rem;
}

.file-item .remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
}

/* Tone Templates */
.tone-templates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tone-btn {
    padding: 0.5rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.tone-btn:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.tone-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    flex-shrink: 0;
}

.chat-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #495057;
    margin: 0;
}

.chat-controls {
    display: flex;
    gap: 0.5rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 2rem;
    min-height: 0;
    max-height: calc(100vh - 300px);
}

.welcome-message {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.welcome-message i {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.welcome-message h3 {
    margin-bottom: 1rem;
    color: #495057;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-content {
    max-width: 70%;
    padding: 1rem;
    border-radius: 15px;
    position: relative;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.assistant .message-content {
    background: #f8f9fa;
    color: #495057;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.chat-input-area {
    padding: 1rem 2rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    flex-shrink: 0;
}

/* Files Area */
.files-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.files-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #495057;
    margin: 0;
}

.files-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    width: 250px;
    font-size: 0.9rem;
}

.search-box i {
    position: absolute;
    right: 0.75rem;
    color: #6c757d;
}

.files-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 2rem;
    overflow: hidden;
}

.files-stats {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.9rem;
    color: #6c757d;
}

.files-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    padding-bottom: 6rem;
    min-height: 0;
    max-height: 60vh;
    height: auto;
}

.file-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.file-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

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

.file-name {
    font-weight: 600;
    color: #495057;
    word-break: break-word;
    flex: 1;
    margin-right: 0.5rem;
}

.file-actions {
    display: flex;
    gap: 0.25rem;
}

.file-actions button {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #6c757d;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.file-actions button:hover {
    background: #e9ecef;
    color: #495057;
}

.file-actions .btn-danger:hover {
    background: #dc3545;
    color: white;
}

.file-info {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    gap: 1rem;
}

.no-files {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.no-files i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.no-files h3 {
    margin-bottom: 0.5rem;
    color: #495057;
}

.input-group {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.input-group textarea {
    flex: 1;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
}

.input-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Status Panel */
.status-panel {
    display: flex;
    justify-content: space-around;
    padding: 1rem 2rem;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    font-size: 0.9rem;
}

/* Google Drive Status Indicator */
#googleDriveStatus {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.status-label {
    color: #6c757d;
    font-weight: 500;
}

.status-value {
    color: #495057;
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: #495057;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-warning:hover {
    background: #e0a800;
}

/* Progress Spinner */
.progress-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* File Viewer Modal */
.file-viewer-content {
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    height: 600px;
    display: flex;
    flex-direction: column;
}

.file-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 1rem;
}

.file-viewer-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-viewer-body {
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 1rem;
    max-height: 400px;
}

.file-viewer-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #495057;
}

/* File Card Improvements */
.file-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    position: relative;
}

.file-card.selected {
    border-color: #667eea;
    background: #f0f2ff;
}

.file-card-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

.file-card-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.file-card-content {
    margin-left: 1.5rem;
}

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

.file-name {
    font-weight: 600;
    color: #495057;
    word-break: break-word;
    flex: 1;
    margin-right: 0.5rem;
    cursor: pointer;
}

.file-name:hover {
    color: #667eea;
    text-decoration: underline;
}

.file-actions {
    display: flex;
    gap: 0.25rem;
}

.file-actions button {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: #6c757d;
    border-radius: 3px;
    transition: all 0.3s ease;
}

.file-actions button:hover {
    background: #e9ecef;
    color: #495057;
}

.file-actions .btn-danger:hover {
    background: #dc3545;
    color: white;
}

.file-actions .btn-info:hover {
    background: #17a2b8;
    color: white;
}

.file-info {
    font-size: 0.8rem;
    color: #6c757d;
    display: flex;
    gap: 1rem;
}

.file-type-badge {
    background: #e9ecef;
    color: #495057;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
}

.file-type-badge.text {
    background: #d4edda;
    color: #155724;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Notification */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .chat-area {
        flex: 1;
    }
    
    .status-panel {
        flex-direction: column;
        gap: 0.5rem;
        display: none !important; /* Hide bottom status panel on mobile */
    }

    /* Hide performance section on mobile */
    #performanceSection {
        display: none !important;
    }

    /* Reclaim space when bottom panels are hidden */
    .files-list {
        padding-bottom: 1rem;
    }
}

/* Message Content Formatting */
.message-content {
    line-height: 1.6;
    word-wrap: break-word;
}

.message-content p {
    margin: 0 0 1em 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content br {
    margin-bottom: 0.5em;
}

/* AI Message Styling */
.ai-message .message-content {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.user-message .message-content {
    background: #e3f2fd;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

/* Performance Section */
.performance-section {
    transition: all 0.3s ease;
}

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

.btn-minimize {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-minimize:hover {
    background: #5a6268;
}

.performance-section.minimized .performance-info {
    display: none;
}

.performance-section.minimized .section-header h3 {
    margin-bottom: 0;
}

/* Performance Optimizations */
.performance-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.performance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #e9ecef;
}

.performance-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.performance-item .label {
    font-weight: 600;
    color: #495057;
}

.performance-item .value {
    color: #6c757d;
    font-family: 'Courier New', monospace;
}

/* Message Meta */
.message-meta {
    margin-top: 8px;
    font-size: 0.8em;
    color: #6c757d;
    display: flex;
    gap: 15px;
}

.message-meta small {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75em;
}
