/* --- Pro UI Redesign --- */
:root {
    --bg-primary: #0b1026;
    --bg-secondary: #27272A;
    --bg-tertiary: #3F3F46;
    --border-color: #3f3f46;
    --text-primary: #E4E4E7;
    --text-secondary: #A1A1AA;
    --accent-primary: #A78BFA;
    --accent-secondary: #8B5CF6;
}

/* Base styles for larger screens (default desktop layout) */
.aidp-wrapper {
    width: 100%;
    min-height: 90vh;
    display: flex; /* Flexbox for side-by-side layout on desktop */
    gap: 1rem;
    font-family: 'Inter', sans-serif;
    background: radial-gradient(900px 520px at 15% 25%, rgba(53,204,204,.35), transparent 60%),
                radial-gradient(800px 480px at 85% 20%, rgba(167,139,250,.42), transparent 62%),
                radial-gradient(900px 600px at 55% 85%, rgba(91,140,255,.30), transparent 60%),
                linear-gradient(180deg, #070b1c, #0b1026 55%, #070b1c);
    position: relative;
    overflow: hidden;
color: var(--text-primary);
    padding: 1rem;
    box-sizing: border-box;
    flex-direction: row; /* Default: row for desktop */
}

.aidp-main-content {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
}

.aidp-product-canvas {
    width: 100%; /* Take full width of its parent */
    max-width: 700px; /* Limit max size */
    height: 700px; /* Fixed height for consistency on desktop */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    overflow: hidden;
}

.aidp-placeholder-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
    text-align: center;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

.aidp-placeholder-text span {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

#aidp-design-canvas {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#aidp-generated-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
    border-radius: 8px;
}

#aidp-generated-image[src=""] {
    display: none;
}

.aidp-controls-panel {
    width: 400px; /* Fixed width for desktop */
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aidp-panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.aidp-panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.aidp-panel-header p {
    margin: 0.25rem 0 0;
    color: var(--text-secondary);
    font-size: 1rem;
}

.aidp-panel-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.aidp-control-group {
    margin-bottom: 1.5rem;
}

.aidp-label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.aidp-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#aidp-guidance-value {
    font-weight: 600;
    color: var(--text-primary);
}

textarea {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-secondary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

.aidp-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    outline: none;
}

.aidp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid var(--bg-secondary);
}

.aidp-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid var(--bg-secondary);
}

.aidp-panel-footer {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.aidp-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.aidp-button-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
}

.aidp-button-primary:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(167, 139, 250, 0.5);
    transform: translateY(-2px);
}

.aidp-button-secondary {
    color: var(--text-primary);
    background-color: #52525B; /* A lighter gray to show it's active */
    margin-top: 0.75rem;
    opacity: 1; /* Full opacity when enabled */
}

.aidp-button-secondary:hover:not(:disabled) {
    background-color: var(--bg-tertiary);
}

.aidp-button:disabled {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
    box-shadow: none;
}

.aidp-button svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

#aidp-loader {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: aidp-spin 1s linear infinite;
    position: absolute;
    display: none;
    z-index: 10; /* Ensure loader is on top */
}

@keyframes aidp-spin {
    to {
        transform: rotate(360deg);
    }
}

.aidp-status-message {
    font-size: 0.875rem;
    text-align: center;
    color: var(--text-secondary);
    min-height: 20px;
    margin-bottom: 1rem;
}

/* --- Responsive Adjustments --- */

/* Tablets and smaller desktops (e.g., up to 1024px) */
@media (max-width: 1024px) {
    .aidp-wrapper {
        flex-direction: column; /* Stack vertically */
        min-height: auto; /* Allow height to adjust */
        padding: 1rem;
    }

    .aidp-main-content {
        width: 100%; /* Take full width */
        order: 1; /* Place main content first */
        padding: 1rem;
    }

    .aidp-product-canvas {
        height: 500px; /* Adjust height for tablets */
        max-width: 100%; /* Ensure it takes full available width */
    }

    .aidp-controls-panel {
        width: 100%; /* Take full width */
        order: 2; /* Place controls second */
        margin-top: 1rem; /* Add some space between sections */
    }

    .aidp-panel-content {
        max-height: 400px; /* Limit height and make it scrollable */
    }
}

/* Smartphones (e.g., up to 768px) */
@media (max-width: 768px) {
    .aidp-wrapper {
        padding: 0.5rem; /* Reduce padding */
        gap: 0.75rem;
    }

    .aidp-product-canvas {
        height: 350px; /* Further reduce height for smaller screens */
        border-radius: 0.75rem; /* Slightly smaller border radius */
    }

    .aidp-placeholder-text {
        font-size: 1rem; /* Smaller font size */
        padding: 1rem;
    }

    .aidp-placeholder-text span {
        font-size: 0.8rem;
    }

    .aidp-controls-panel {
        border-radius: 0.75rem; /* Slightly smaller border radius */
    }

    .aidp-panel-header {
        padding: 1rem; /* Reduce header padding */
    }

    .aidp-panel-header h2 {
        font-size: 1.3rem; /* Smaller heading font */
    }

    .aidp-panel-header p {
        font-size: 0.9rem;
    }

    .aidp-panel-content {
        padding: 1rem; /* Reduce content padding */
        max-height: 300px; /* Adjust max height for even smaller screens */
    }

    .aidp-control-group {
        margin-bottom: 1rem; /* Reduce margin between control groups */
    }

    .aidp-label {
        font-size: 0.8rem; /* Smaller label font */
        margin-bottom: 0.4rem;
    }

    textarea {
        padding: 0.6rem; /* Smaller textarea padding */
        font-size: 0.9rem;
    }

    .aidp-button {
        font-size: 1rem; /* Smaller button font */
        padding: 0.7rem 0.8rem; /* Adjust button padding */
        gap: 0.5rem;
    }

    .aidp-button svg {
        width: 1rem;
        height: 1rem;
    }

    .aidp-panel-footer {
        padding: 1rem; /* Reduce footer padding */
    }

    .aidp-button-secondary {
        margin-top: 0.6rem; /* Adjust margin */
    }

    .aidp-status-message {
        font-size: 0.8rem; /* Smaller status message font */
        margin-bottom: 0.8rem;
    }

    #aidp-loader {
        width: 40px; /* Smaller loader */
        height: 40px;
        border-width: 3px;
    }
}

/* Very small smartphones (e.g., up to 480px) */
@media (max-width: 480px) {
    .aidp-product-canvas {
        height: 300px; /* Even smaller height for very small screens */
    }

    .aidp-panel-content {
        max-height: 250px; /* Adjust max height */
    }
}

/* --- MultiGen additions --- */
.aidp-mode{
  display:flex;
  gap:.6rem;
  flex-wrap: wrap;
}
.aidp-radio{
  flex: 1 1 auto;
  display:flex;
  align-items:center;
  gap:.55rem;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  border-radius: 14px;
  padding: .65rem .75rem;
  cursor: pointer;
}
.aidp-radio input{ accent-color: var(--accent-primary); }
.aidp-radio span{ font-weight: 800; }
.aidp-radio small{
  margin-left:auto;
  color: var(--text-secondary);
  font-weight: 600;
}
.aidp-upload{
  display:flex;
  gap:.75rem;
  align-items:center;
  border:1px dashed rgba(255,255,255,.18);
  background: rgba(0,0,0,.18);
  border-radius: 14px;
  padding:.85rem;
}
.aidp-upload input[type=file]{
  width: 160px;
  max-width: 45%;
  color: var(--text-secondary);
}
.aidp-upload-meta{
  flex: 1 1 auto;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: .75rem;
}
.aidp-upload-name{
  color: var(--text-secondary);
  font-weight: 700;
  font-size: .9rem;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.aidp-ref-preview{
  margin-top:.75rem;
  border:1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  overflow:hidden;
  background: rgba(255,255,255,.04);
}
.aidp-ref-preview img{
  width:100%;
  height: 180px;
  object-fit: contain;
  display:block;
}
@media (max-width: 768px){
  .aidp-upload{ flex-direction: column; align-items: stretch; }
  .aidp-upload input[type=file]{ width:100%; max-width:100%; }
  .aidp-upload-name{ max-width: 100%; }
}

/* Vivid flare background layers */
.aidp-wrapper::before,
.aidp-wrapper::after{
  content:"";
  position:absolute;
  inset:-20%;
  pointer-events:none;
  z-index:0;
}
.aidp-wrapper::before{
  background:
    repeating-linear-gradient(120deg,
      transparent 0 18px,
      rgba(255,255,255,.08) 18px 19px,
      transparent 19px 44px);
  opacity:.10;
  transform: rotate(-10deg);
  mask-image: radial-gradient(circle at 50% 50%, rgba(0,0,0,1), transparent 68%);
}
.aidp-wrapper::after{
  background:
    radial-gradient(circle at 20% 30%, rgba(53,204,204,.35), transparent 55%),
    radial-gradient(circle at 80% 20%, rgba(167,139,250,.40), transparent 58%),
    radial-gradient(circle at 55% 85%, rgba(91,140,255,.28), transparent 60%);
  filter: blur(10px);
  opacity:.85;
  animation: aidp-float 12s ease-in-out infinite;
}
@keyframes aidp-float{
  0%,100%{ transform: translate3d(0,0,0) scale(1); }
  50%{ transform: translate3d(0,-18px,0) scale(1.03); }
}

/* Ensure panels sit above background */
.aidp-main-content,
.aidp-controls-panel{
  position: relative;
  z-index: 1;
}
