/* --- Modern UI Style System --- */
:root {
    --primary-color: #4A55E1; /* Indigo */
    --primary-color-hover: #404AD1;
    --sidebar-bg: #F7F8FA;
    --border-color: #EAEBEE;
    --text-primary: #1A1A1A;
    --text-secondary: #6c757d;
    --white: #ffffff;
    --danger-color: #dc3545;
    --dark-gray: #343a40;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Noto Serif SC', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; color: var(--text-primary); }
.app-container { display: flex; height: 100vh; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); }

/* --- Sidebar Redesign --- */
.sidebar { 
    width: 320px; 
    background: var(--sidebar-bg); 
    border-right: 1px solid var(--border-color); 
    padding: 24px; 
    overflow-y: auto; 
}
.section-title { 
    font-size: 16px; 
    font-weight: 600; 
    margin-bottom: 16px; 
    color: var(--text-primary);
    margin-top: 32px; /* Increased spacing between sections */
}
.sidebar > .section-title:first-child {
    margin-top: 0;
}

/* --- Template Card Redesign --- */
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.template-card { 
    background: var(--white); 
    border: 1px solid var(--border-color);
    border-radius: 8px; 
    cursor: pointer; 
    transition: all 0.2s ease-in-out; 
    overflow: hidden; 
    text-align: center; 
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--white);
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.template-card:hover { 
    transform: translateY(-4px); 
    box-shadow: 0 8px 20px rgba(74, 85, 225, 0.1);
    border-color: var(--primary-color);
}
.template-card.active { 
    box-shadow: 0 0 0 3px rgba(74, 85, 225, 0.4);
    border-color: var(--primary-color);
}

.form-group { margin-bottom: 15px; }
.form-label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-secondary); font-size: 14px; }

/* --- Main Content Area --- */
.main-content { flex: 1; display: flex; flex-direction: column; background: var(--white); }
.toolbar { height: 60px; background: var(--dark-gray); color: var(--white); display: flex; align-items: center; padding: 0 20px; gap: 10px; position: relative; }
.canvas-area { flex: 1; display: flex; justify-content: center; align-items: center; padding: 20px; background: #f1f3f4; position: relative; }
.canvas-container { background: var(--white); border-radius: 8px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); }

/* --- General Controls --- */
.form-control { width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 14px; transition: border-color 0.3s ease; }
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(74, 85, 225, 0.25); }

.color-input-wrapper { position: relative; width: 100%; height: 38px; background: #ddd; border-radius: 6px; border: 1px solid #ced4da; }
.color-input-wrapper input[type="color"] { width: 100%; height: 100%; cursor: pointer; opacity: 0; }
.color-input-wrapper::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-color, #ffffff); border-radius: 5px; pointer-events: none; }

.btn { padding: 10px 20px; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s ease; width: 100%; }
.btn-primary { background: var(--primary-color); color: var(--white); }
.btn-primary:hover { background: var(--primary-color-hover); transform: translateY(-1px); }
.btn-danger { background: var(--danger-color); color: var(--white); }
.btn-danger:hover { background: #c82333; }
.btn-secondary { background: #6c757d; color: var(--white); }
.btn-secondary:hover { background: #5a6268; }

.color-picker-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 10px; }
.color-option { width: 100%; padding-bottom: 100%; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.2s ease; position: relative; }
.color-option:hover { transform: scale(1.1); }
.color-option.active { border-color: var(--primary-color); }

.properties-panel { background: var(--sidebar-bg); border-top: 1px solid var(--border-color); padding: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.prop-group { display: flex; flex-direction: column; }
.prop-group label { font-size: 12px; margin-bottom: 4px; color: var(--text-secondary); }
.prop-group input[type="color"] { width: 40px; height: 25px; padding: 2px; border-radius: 4px; border: 1px solid #ced4da; cursor: pointer; }

.btn-group { display: flex; gap: 5px; }
.prop-btn { background: var(--white); border: 1px solid #ced4da; border-radius: 4px; padding: 5px 8px; cursor: pointer; transition: background 0.2s; }
.prop-btn:hover { background: #e2e6ea; }
.prop-btn.active { background: var(--primary-color); color: var(--white); border-color: var(--primary-color); }
.prop-btn svg { width: 16px; height: 16px; fill: #333; vertical-align: middle; }
.prop-btn.active svg { fill: var(--white); }

.tool-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.3); color: var(--white); padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 5px; }
.tool-btn:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.5); }
.tool-btn.active { background: var(--primary-color); border-color: var(--primary-color); }
.tool-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.dropdown-menu { position: relative; }
.dropdown-menu .dropdown-content { display: none; position: absolute; right: 0; top: 110%; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 101; border-radius: 4px; overflow: hidden; }
.dropdown-menu:hover .dropdown-content { display: block; }
.dropdown-menu .dropdown-content button, .dropdown-menu .dropdown-content .dropdown-item { background-color: var(--white); color: black; padding: 12px 16px; text-decoration: none; display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; border: none; font-size: 14px; }
.dropdown-menu .dropdown-content button:hover, .dropdown-menu .dropdown-content .dropdown-item:hover { background-color: #f1f1f1; }
.dropdown-header { padding: 10px 16px; font-size: 12px; color: var(--text-secondary); background-color: #f1f1f1; }
.draft-delete-btn { background: none; border: none; cursor: pointer; color: var(--danger-color); padding: 4px; border-radius: 4px; }
.draft-delete-btn:hover { background: #e2e6ea; }

.shape-modal { position: absolute; top: 65px; left: 50%; transform: translateX(-50%); background: var(--white); border-radius: 8px; padding: 15px; display: none; grid-template-columns: repeat(3, 1fr); gap: 15px; z-index: 100; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.shape-option { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; background: #f1f3f4; border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.shape-option:hover { background: #e2e6ea; transform: scale(1.05); }
.shape-option svg { width: 32px; height: 32px; fill: #555; }

.upload-group { margin-top: 10px; }
.disclaimer { font-size: 11px; color: var(--text-secondary); text-align: center; margin-top: 8px; }
.materials-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 15px; }
.material-thumb { width: 100%; padding-bottom: 100%; background-size: cover; background-position: center; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s ease; }
.material-thumb:hover { border-color: var(--primary-color); opacity: 0.8; }

.filter-item { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.filter-item label { font-size: 14px; color: var(--text-secondary); }
.filter-item input[type="range"] { flex: 1; margin-left: 10px; }

/* --- Modal Styles --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-content { background: var(--white); padding: 30px; border-radius: 8px; max-width: 450px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); text-align: center; }
.modal-title { font-size: 20px; font-weight: 600; margin-bottom: 15px; }
.modal-body { font-size: 15px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 25px; text-align: left; }
.modal-body p { margin-bottom: 10px; }
.modal-body b { color: var(--danger-color); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Keyframes for notifications */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}
