/* =============================================== */
/* == 1. CẤU HÌNH CHUNG & LAYOUT                == */
/* =============================================== */
:root {
    --ge-primary: #8A2BE2; /* Màu tím Graffiti */
    --ge-bg-gray: #f3f4f6;
    --ge-border: #e5e7eb;
    --ge-text: #1f2937;
}

.ge-app-wrapper, .ge-app-wrapper * { box-sizing: border-box; }

.ge-app-wrapper {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #fff;
    border: 1px solid var(--ge-border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    margin: 20px auto;
    width: 100%; 
    height: 85vh; /* Chiều cao cố định theo màn hình */
    min-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ge-header {
    padding: 15px 25px;
    border-bottom: 1px solid var(--ge-border);
    background: #fff;
    flex-shrink: 0;
}
.ge-header h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--ge-text); }

.ge-main-container {
    display: flex;
    flex: 1; /* Chiếm hết chiều cao còn lại */
    overflow: hidden;
}

/* --- CỘT TRÁI (CÔNG CỤ) --- */
.ge-controls-panel {
    width: 320px; /* Độ rộng cố định */
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--ge-border);
    padding: 20px;
    overflow-y: auto;
}

/* --- CỘT PHẢI (PREVIEW) --- */
.ge-preview-area {
    flex: 1;
    background: var(--ge-bg-gray);
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}

/* =============================================== */
/* == 2. CANVAS PREVIEW AREA (FIX HIỂN THỊ)     == */
/* =============================================== */
.ge-canvas-wrapper-outer {
    flex: 1;
    background: var(--ge-bg-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Tờ giấy trắng */
.ge-canvas-container {
    background: #fff;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    
    /* QUAN TRỌNG: Set kích thước tối thiểu để không bị biến mất */
    min-width: 300px;
    min-height: 300px;
    
    /* Fit Height logic */
    height: 90%; 
    width: auto;
    aspect-ratio: 1/1; /* Giữ khung vuông mặc định */
    
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Ép FabricJS theo CSS */
.ge-canvas-container .canvas-container {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
}

.ge-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain; 
    display: block !important;
}

/* =============================================== */
/* == 3. CONTROLS STYLING                       == */
/* =============================================== */
.ge-control-group { margin-bottom: 18px; }
.ge-control-group label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: #6b7280; margin-bottom: 6px; display: block; }

.ge-textarea {
    width: 100%; padding: 10px; border: 1px solid var(--ge-border);
    border-radius: 6px; background: #f9fafb; font-size: 16px;
}

/* Font Grid */
.ge-font-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px;
}
.ge-font-item {
    height: 50px; border: 1px solid var(--ge-border); border-radius: 6px; background: #fff;
    cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.ge-font-item:hover { border-color: var(--ge-primary); }
.ge-font-item.active { background: var(--ge-primary); color: #fff; border-color: var(--ge-primary); }

/* Slider */
.ge-slider { width: 100%; height: 4px; background: #e5e7eb; border-radius: 2px; -webkit-appearance: none; }
.ge-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: var(--ge-primary); cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Paper Ratio Buttons */
.ge-pager-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ge-pager-btn {
    padding: 8px; border: 1px solid var(--ge-border); background: #fff; border-radius: 6px;
    cursor: pointer; font-size: 12px; font-weight: 600; text-align: center;
}
.ge-pager-btn.active { background: var(--ge-primary); color: #fff; border-color: var(--ge-primary); }


/* =============================================== */
/* == 4. BOTTOM TOOLBAR & BUTTONS               == */
/* =============================================== */
.ge-bottom-toolbar {
    background: #fff;
    padding: 15px 25px;
    border-top: 1px solid var(--ge-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 20;
}

/* Share Buttons */
.ge-social-share { display: flex; gap: 10px; }
.ge-share-btn {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; text-decoration: none; transition: 0.2s;
}
.ge-share-btn:hover { transform: translateY(-2px); }
.ge-share-btn .dashicons { font-size: 18px; width: 18px; height: 18px; line-height: 18px; }

.ge-share-btn.fb { background: #1877f2; }
.ge-share-btn.tw { background: #000000; }
.ge-share-btn.pt { background: #e60023; padding-top: 0px !important;}
.ge-share-btn.link { background: #6b7280; }

/* Download Button */
.ge-btn-download {
    background: var(--ge-primary); color: #fff; border: none;
    height: 36px; padding: 0 20px; border-radius: 18px;
    font-weight: 700; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; gap: 6px;
}
.ge-btn-download:hover { background: #7b27cc; transform: translateY(-1px); }
.ge-btn-download .dashicons { font-size: 18px; width: 18px; height: 18px; }

/* =============================================== */
/* == 5. RESPONSIVE                             == */
/* =============================================== */
@media (max-width: 900px) {
    .ge-app-wrapper { height: auto; border: none; margin: 0; border-radius: 0;}
    .ge-main-container { flex-direction: column-reverse; }
    
    .ge-controls-panel { width: 100%; border-right: none; border-top: 1px solid var(--ge-border); }
    
    .ge-canvas-wrapper-outer { height: 50vh; min-height: 300px; padding: 20px; }
    .ge-canvas-container { height: 100%; width: auto; }
    
    .ge-bottom-toolbar { flex-direction: column; gap: 15px; }
}