/* minimal modal styles for final preview */
#finalModal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  padding: 20px;
}
#finalModal .modal-card {
  background: #fff;
  max-width: 920px;
  width: 100%;
  max-height: 95vh;
  overflow: auto;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.4);
}
#finalPreviewImg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 6px auto;
  border: 1px solid #ddd;
  background: #fff;
}
#finalModal .modal-actions {
  display:flex;
  gap:8px;
  justify-content:flex-end;
  margin-top:8px;
}
#finalModal button { padding:8px 12px; cursor:pointer; }

/* styles.css का content */
/* Global Styles */
body {
    font-family: system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: #f6f7fb;
    margin: 0;
    padding: 12px;
    color: #333;
}

/* Header Section (Removed logo, not available) */
.header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

/* Main Layout Grid */
.wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.panel {
    background: #fff;
    padding: 14px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Section Headings */
h2 {
    margin: 0 0 15px;
    font-size: 16px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* Form Fields */
.form-group {
    margin-bottom: 15px;
}
label {
    display: block;
    font-size: 13px;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}
.field, .field-row input, .field-row select, .field-row input[type="color"], .field-row input[type="range"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db; /* neutral border */
    border-radius: 10px;
    box-sizing: border-box; 
    background: #ffffff;
    transition: box-shadow .2s ease, border-color .2s ease, background-color .2s ease;
}
.field-row select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6b7280 50%), linear-gradient(135deg, #6b7280 50%, transparent 50%), linear-gradient(to right, #d1d5db, #d1d5db);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px), calc(100% - 42px) 50%;
    background-size: 6px 6px, 6px 6px, 1px 60%;
    background-repeat: no-repeat;
    cursor: pointer;
}
.field-row select:hover {
    border-color: #9ca3af;
}
.field-row select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.form-group select#templateSelector,
.style-row select#fontSelector {
    font-weight: 600;
    color: #1f2937;
}
.style-row select#fontSelector option[value="Algerian"] { font-family: Algerian; }
.style-row select#fontSelector option[value="Arial"] { font-family: Arial; }
.style-row select#fontSelector option[value="Verdana"] { font-family: Verdana; }
.style-row select#fontSelector option[value="Times New Roman"] { font-family: 'Times New Roman'; }

/* Make only the controls-panel super colorful and eye-catching */
.controls-panel {
  background: linear-gradient(135deg, #ffb6d4 0%, #ffecd2 40%, #a1c4fd 100%);
  border-radius: 28px;
  box-shadow: 0 12px 48px 0 rgba(221,36,118,0.18), 0 4px 16px 0 rgba(44,62,80,0.12);
  padding: 42px 34px 32px 34px;
  margin: 24px 0 24px 24px;
  min-width: 350px;
  max-width: 420px;
  transition: box-shadow 0.3s, transform 0.2s;
  position: relative;
  z-index: 2;
  overflow: hidden;
  animation: rainbowGlow 3s linear infinite alternate;
}

@keyframes rainbowGlow {
  0% { box-shadow: 0 0 24px 0 #ffb6d5, 0 4px 16px 0 #a1c4fd; }
  100% { box-shadow: 0 0 36px 8px #a1c4fd, 0 4px 16px 0 #ffb6d5; }
}

.controls-panel::before {
  content: "";
  position: absolute;
  top: -70px;
  left: -70px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, #ff512f 0%, #ffb6d5 60%, transparent 100%);
  z-index: 0;
  opacity: 0.25;
  pointer-events: none;
}

.controls-panel::after {
  content: "";
  position: absolute;
  bottom: -60px;
  right: -60px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, #a1c4fd 0%, #ffecd2 80%, transparent 100%);
  z-index: 0;
  opacity: 0.22;
  pointer-events: none;
}

.controls-panel h2 {
  background: linear-gradient(90deg, #ff512f 0%, #dd2476 100%);
  color: #fff;
  padding: 20px 0 20px 26px;
  border-radius: 20px 20px 0 0;
  margin: -42px -34px 32px -34px;
  font-size: 2rem;
  letter-spacing: 2px;
  box-shadow: 0 2px 18px 0 rgba(221,36,118,0.13);
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 12px rgba(221,36,118,0.13);
  font-family: 'Poppins', 'Segoe UI', Arial, sans-serif;
}

/* Upload Box (Green & Centered) */
.upload-area {
  background: #44e2e7;
  border: 1.5px dashed #dd2476;
  border-radius: 12px;
  padding: 18px 12px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: border-color 0.2s;
}

.upload-area:hover {
  border-color: #ff512f;
}

.upload-box {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  color: #dd2476;
  font-size: 1.1rem;
}

.upload-icon {
  font-size: 1.5rem;
}

#uploadedFileName {
  margin-top: 8px;
  font-size: 0.95rem;
  color: #888;
}

.form-group, .field-row, .style-row {
  margin-bottom: 18px;
}

label {
  font-weight: 600;
  color: #222;
  margin-bottom: 6px;
  display: block;
  letter-spacing: 0.5px;
}

input[type="text"], select, input[type="color"] {
  border-radius: 8px;
  border: 1.5px solid #e0e0e0;
  padding: 7px 12px;
  font-size: 1rem;
  margin-top: 4px;
  width: 100%;
  transition: border-color 0.2s;
  background: #fafbfc;
}

input[type="text"]:focus, select:focus, input[type="color"]:focus {
  border-color: #dd2476;
  outline: none;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-half {
  flex: 1;
}

.style-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* हर बच्चा कॉलम के रूप में रहे (label ऊपर, control नीचे) और बराबर जगह ले */
.style-row > div{
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* label और control के बीच थोड़ी जगह */
.style-row label{
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

/* Buttons */
.btn-group {
    margin-top: 20px;
    text-align: center;
}
.btn {
    display: inline-block;
    padding: 10px 15px;
    margin: 5px;
    border-radius: 8px;
    background: #3b82f6; /* Default blue for Submit */
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn:hover {
    background: #2563eb;
}
.btn.blue { background: #3b82f6; } 
.btn.red { background: #ef4444; } /* Reset button style */
.btn.pink { background: #dd2476; font-size: 1.1rem; padding: 12px 20px; box-shadow: 0 4px 10px rgba(221,36,118,0.3); } /* Final Preview button style */


/* Canvas and Preview - IMPORTANT: Fabric.js creates a wrapper div */
.canvas-wrap {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.canvas-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    background: #fff; /* Set background on the container/canvas */
}

/* Mobile Optimization */
@media(max-width: 768px) {
    .wrap {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .controls-panel {
        margin: 0 auto 20px;
        padding: 25px 20px;
        max-width: 100%;
        min-width: auto;
        border-radius: 20px;
    }
    
    .controls-panel h2 {
        font-size: 1.5rem;
        padding: 15px 0 15px 20px;
        margin: -25px -20px 25px -20px;
    }
    
    .field-row, .style-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .field-half {
        width: 100%;
    }
    
    .canvas-wrap {
        overflow-x: auto;
    }
    
    .canvas-wrap canvas {
        max-width: 100%;
        height: auto;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .btn {
        width: 100%;
        margin: 0;
    }
    
    .upload-area {
        padding: 15px 10px;
    }
    
    .upload-box {
        font-size: 1rem;
    }
    
    .upload-icon {
        font-size: 1.3rem;
    }
    
    #finalModal .modal-card {
        margin: 10px;
        padding: 10px;
    }
    
    #finalModal .modal-actions {
        flex-direction: column;
    }
}

/* Extra small devices */
@media(max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .panel {
        padding: 12px;
    }
    
    .controls-panel {
        padding: 20px 15px;
    }
    
    .controls-panel h2 {
        font-size: 1.3rem;
        padding: 12px 0 12px 15px;
        margin: -20px -15px 20px -15px;
    }
    
    input[type="text"], select, input[type="color"] {
        padding: 8px 10px;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .btn.pink {
        font-size: 1rem;
        padding: 10px 16px;
    }
}