/* --- Bố cục tổng thể --- */
body {
    background-color: #f0f2f5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0; /* Loại bỏ padding body để tối ưu không gian */
    overflow: hidden; /* Ngăn cuộn trang để trải nghiệm như ứng dụng desktop */
}

.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    width: 95vw; /* Chiếm 95% chiều rộng màn hình */
    height: 90vh; /* Chiếm 90% chiều cao màn hình */
    max-width: 1600px;
}

/* --- Cột trái: Khu vực vẽ (Đã tối ưu Responsive) --- */
.drawing-area {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1; /* Tự động lấy hết phần không gian còn lại */
    height: 100%;
}

.canvas-wrapper {
    position: relative;
    /* Tự động tính toán kích thước dựa trên không gian khả dụng */
    width: 100%;
    height: 100%; 
    background: #111; 
    border-radius: 16px;
    border: 4px solid #333;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    
    /* Căn giữa các Canvas bên trong */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Lớp Canvas: Kích thước pixel thực tế sẽ do DrawingManager điều khiển */
#imageCanvas, #drawCanvas {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.3s;
}

#drawCanvas {
    z-index: 3;
}

/* --- Cột phải: Camera & Hướng dẫn (Cố định chiều rộng) --- */
.guide-panel {
    width: 300px;
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    border: 1px solid #e1e4e8;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Cho phép cuộn nếu màn hình quá thấp */
}

/* Container cho Camera */
.camera-container {
    position: relative;
    width: 100%;
    min-height: 180px;
    background: #000;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 3px solid #0984e3;
    flex-shrink: 0;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #0984e3;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    z-index: 5;
}

.guide-panel h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Các mục hướng dẫn */
.guide-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.gesture-icon {
    font-size: 22px;
    background: #f8f9fa;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    flex-shrink: 0;
}

.guide-info strong {
    display: block;
    font-size: 13px;
    color: #2d3436;
}

.guide-info span {
    font-size: 11px;
    color: #636e72;
    line-height: 1.2;
}

/* --- CÀI ĐẶT CỌ VẼ --- */
.brush-settings {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #f0f2f5;
}

.brush-settings h4 {
    margin: 10px 0 10px 0;
    font-size: 14px;
    color: #1a1a1a;
    font-weight: 600;
}

/* Bảng màu */
.color-palette {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.color-item {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 0 0 1px #dfe6e9;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.color-item:hover {
    transform: scale(1.15);
}

.color-item.active {
    box-shadow: 0 0 0 2px #0984e3;
    transform: scale(1.1);
}

/* Thanh độ dày cọ */
.size-control-group {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
}

#brush-size-val {
    color: #0984e3;
    font-weight: 800;
}

.size-indicator-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin-top: 10px;
    overflow: hidden;
}

#size-fill {
    width: 10%; 
    height: 100%;
    background: linear-gradient(90deg, #0984e3, #00cec9);
    transition: width 0.1s ease;
}

/* --- Khu vực điều khiển (Dưới khung vẽ) --- */
.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    background: white;
    padding: 12px;
    border-radius: 14px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

button, .custom-file-upload {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-file-upload {
    background-color: #f1f2f6;
    color: #2d3436;
    border: 1px solid #dfe6e9;
}
.custom-file-upload:hover { background: #e2e4e9; }

#clearBtn {
    background-color: #ff7675;
    color: white;
}
#clearBtn:hover { 
    background-color: #d63031;
    transform: translateY(-1px);
}

#downloadBtn {
    background-color: #00b894;
    color: white;
}
#downloadBtn:hover { 
    background-color: #00947a;
    transform: translateY(-1px);
}

#status {
    margin-top: auto; /* Đẩy xuống cuối bảng điều khiển */
    font-size: 11px;
    font-weight: 700;
    color: #2d3436;
    padding: 10px;
    background: #f1f2f6;
    border-radius: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}