* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
    flex-shrink: 0;
}

header h1 {
    font-size: 2em;
    margin-bottom: 5px;
}

header p {
    opacity: 0.9;
    font-size: 0.95em;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.upload-column,
.view-column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
    overflow: hidden;
}

.view-column {
    border-right: none;
    border-left: 1px solid #e0e0e0;
}

.column-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.column-header h2 {
    font-size: 1.3em;
    color: #667eea;
    margin: 0;
}

.upload-form {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
    cursor: pointer;
}

small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 0.85em;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    width: auto;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #5568d3;
}

.status {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Chat Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.key-input-section {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.key-input-section input {
    flex: 1;
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f0f2f5;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.placeholder-message {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 40px 20px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
    position: relative;
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
    margin-bottom: 8px;
}

.message-image {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin-top: 8px;
    display: block;
}

.message-time {
    font-size: 0.75em;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

.message-status {
    display: inline-block;
    font-size: 0.7em;
    color: #667eea;
    margin-left: 5px;
}

/* QR Code Modal */
.qr-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.qr-modal-content {
    background-color: white;
    margin: 2vh auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
    overflow: hidden;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px 20px 0 0;
}

.qr-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.qr-close {
    background: none;
    border: none;
    font-size: 2em;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    transition: transform 0.2s;
}

.qr-close:hover {
    transform: rotate(90deg);
}

.qr-modal-body {
    padding: 30px;
    padding-bottom: 30px;
    text-align: center;
    overflow-y: auto;
    flex: 1;
    max-height: calc(90vh - 80px);
}

.qr-modal-body .form-group {
    margin-bottom: 5px;
    text-align: left;
}

.qr-modal-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

.qr-modal-body .form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.qr-modal-body .form-group input:focus {
    outline: none;
    border-color: #667eea;
}

#qr-code-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    background: #f9f9f9;
    border-radius: 10px;
    padding: 15px;
}

#qr-code-container p {
    color: #666;
    font-style: italic;
}

#qr-code-container canvas,
#qr-code-container img {
    max-width: 100%;
    width: 200px;
    height: auto;
    border-radius: 10px;
}

.qr-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.qr-actions .btn {
    flex: 1;
    padding: 12px 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .upload-column {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 50vh;
    }
    
    .view-column {
        border-left: none;
    }
    
    .qr-modal-content {
        width: 95%;
        margin: 2vh auto;
        max-height: 95vh;
    }
    
    .qr-modal-body {
        max-height: calc(95vh - 80px);
        padding: 20px;
        padding-bottom: 20px;
    }
    
    .qr-actions {
        flex-direction: column;
    }
}
