* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

h1 {
    color: #FFD700;
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.subtitle {
    color: #666;
    font-size: 1.2em;
}

/* mode selector */
.mode-selector {
    display: flex;
    justify-content: left;
    gap: 20px;
    margin-bottom: 30px;
}

.mode-btn {
    background: white;
    border: 2px solid #FFD700;
    color: #333;
    padding: 15px 40px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.mode-btn:hover {
    background: #FFF9C4;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.mode-btn.active {
    background: #FFD700;
    color: #2E8B57;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover {
    border-color: #FFD700;
    background: #fff9e6;
}

.upload-area i {
    font-size: 48px;
    color: #FFD700;
    margin-bottom: 15px;
}

.file-input {
    display: none;
}

.upload-btn {
    background: #FFD700;
    color: #333;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
    margin-top: 10px;
}

.upload-btn:hover {
    background: #ffcc00;
    transform: translateY(-2px);
}

.camera-container {
    position: relative;
    width: 100%;
    height: 265px;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.camera-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
    transition: all 0.3s;
}

.camera-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.camera-btn.secondary {
    background: #f44336;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
    transition: all 0.3s;
}

.camera-btn.secondary:hover {
    background: #da190b;
}

.camera-select {
    max-width: 100px;
    padding: 5px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
    /* min-width: 180px;
    padding: 10px 14px;
    border-radius: 25px;
    border: 2px solid #ddd;
    font-size: 14px;
    margin-top: 10px;
    margin-right: 10px; */
}

.chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    height: 420px;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: #FFD700;
    color: #333;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    font-weight: bold;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 18px;
    border-radius: 18px;
    line-height: 1.4;
}

.message.bot {
    background: #f0f0f0;
    align-self: flex-start;
    border-radius: 18px 18px 18px 4px;
}

.message.user {
    background: #FFD700;
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input input:focus {
    border-color: #FFD700;
}

.chat-input button {
    background: #FFD700;
    color: #333;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.chat-input button:hover {
    background: #ffcc00;
    transform: translateY(-2px);
}

.detection-result {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    margin-top: 20px;
    display: none;
}

.detection-image {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 15px;
}

.quality-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 10px;
    transition: all 0.3s;
}

.quality-btn:hover {
    background: #0b7dda;
    transform: translateY(-2px);
}

.detection-count {
    font-size: 18px;
    color: #333;
    margin-bottom: 10px;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #FFD700;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* History Page */
.history-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.back-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    transition: all 0.3s;
}

.back-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.history-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: all 0.3s;
    border: 1px solid #e0e0e0;
}

.history-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.history-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 2px solid #FFD700;
}

.history-info {
    padding: 20px;
}

.history-info h3 {
    color: #2E8B57;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.history-info p {
    color: #666;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.view-detection-btn {
    display: block;
    width: 100%;
    background: #FFD700;
    color: #333;
    text-align: center;
    padding: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s;
}

.view-detection-btn:hover {
    background: #FFC107;
}

.empty-history {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-history i {
    font-size: 64px;
    margin-bottom: 20px;
    color: #ccc;
}

/* Detection Page */
.detection-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.detection-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

.image-container {
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.image-container h3 {
    text-align: center;
    margin-bottom: 15px;
    color: #2E8B57;
}

.detection-img {
    width: 100%;
    border-radius: 10px;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.detection-info {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.detection-info h2 {
    color: #2E8B57;
    margin-bottom: 20px;
    text-align: center;
}

.detection-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border-left: 6px solid #FFD700;
}

.stat-box h4 {
    color: #666;
    margin-bottom: 10px;
    font-size: 0.9em;
    text-transform: uppercase;
}

.stat-box .stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #2E8B57;
}

.quality-report {
    background: #FFF9C4;
    padding: 25px;
    border-radius: 10px;
    border: 1px solid #FFD700;
    white-space: pre-line;
    line-height: 1.6;
}

.detection-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.image-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.image-preview img {
    max-width: 90%;
    max-height: 90%;
    border: 3px solid white;
    border-radius: 10px;
}

.close-preview {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: rgba(0,0,0,0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container img {
    cursor: pointer;
    transition: transform 0.3s;
}

.image-container img:hover {
    transform: scale(1.02);
}

.action-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

.action-btn.secondary {
    background: #2196F3;
}

.action-btn.secondary:hover {
    box-shadow: 0 4px 12px rgba(33,150,243,0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .detection-images {
        grid-template-columns: 1fr;
    }
    
    .mode-selector {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
    
    .upload-controls,
    .camera-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .action-btn,
    .camera-btn {
        width: 100%;
        max-width: 300px;
        justify-content: center;
    }
    
    .history-grid {
        grid-template-columns: 1fr;
    }
}
