/* Copy all styles from original frontend.html <style> section */
.ai-editor-wrapper * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.ai-editor-wrapper {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
        Cantarell, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2%;
    color: #ffffff;
}

.ai-editor-wrapper button {
    font-family: inherit;
    border: none;
    outline: none;
    background: none;
    padding: 0;
    margin: 0;
}

.ai-editor-container {
    background: #000000;
    padding: 3%;
    border: 1px solid #333;
}

.ai-editor-container h1 {
    color: #ffffff;
    margin-top: 0;
    font-size: 28px;
    margin-bottom: 10px;
    text-align: center;
}

.ai-editor-subtitle {
    color: #b296ff;
    margin-bottom: 30px;
    font-size: 14px;
    text-align: center;
}

.ai-editor-upload-area {
    border: 3px dashed #444;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #000000;
}

.ai-editor-upload-area:hover {
    border-color: #b296ff;
    background: #111111;
}

.ai-editor-upload-area.ai-editor-dragover {
    border-color: #b296ff;
    background: #1a1a1a;
}

.ai-editor-upload-text {
    color: #ffffff;
    font-size: 18px;
    margin-bottom: 10px;
}

.ai-editor-upload-subtext {
    color: #808090;
    font-size: 14px;
}

.ai-editor-file-input {
    display: none;
}

.ai-editor-preview-container {
    display: grid;
    gap: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
    align-items: start;
}

.ai-editor-preview-item {
    position: relative;
    border: 1px solid #333;
    background: #1a1a1a;
    padding: 10px;
}

.ai-editor-preview-image-wrapper {
    position: relative;
    width: 100%;
}

.ai-editor-preview-item img {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    border: 1px solid #b296ff;
}

.ai-editor-preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 10px;
}

.ai-editor-selection-indicator {
    position: absolute;
    border: 2px dashed #b296ff;
    background: rgba(178, 150, 255, 0.15);
    pointer-events: none;
    display: none;
    z-index: 1;
}

.ai-editor-selection-indicator.active {
    display: block;
}

.ai-editor-btn {
    background: #b296ff !important;
    color: #000000 !important;
    padding: 8px 12px !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 12px !important;
    transition: background 0.3s !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600 !important;
    text-align: center !important;
}

.ai-editor-btn:hover:not(:disabled) {
    background: #9d7ee8 !important;
}

.ai-editor-btn:disabled {
    background: #333333 !important;
    cursor: not-allowed !important;
    color: #666666 !important;
}

.ai-editor-btn-danger {
    background: #666 !important;
    color: #fff !important;
}

.ai-editor-btn-danger:hover {
    background: #888 !important;
}

.ai-editor-form-section {
    margin-bottom: 20px;
}

.ai-editor-label {
    display: block;
    margin-bottom: 8px;
    color: #cccccc;
    font-size: 14px;
}

.ai-editor-input,
.ai-editor-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #333;
    background: #000000;
    color: #ffffff;
    font-size: 14px;
    font-family: inherit;
}

.ai-editor-input:focus,
.ai-editor-textarea:focus {
    outline: none;
    border-color: #b296ff;
}

.ai-editor-textarea {
    resize: vertical;
    min-height: 80px;
}

.ai-editor-generate-btn {
    width: 100%;
    padding: 16px !important;
    background: #b296ff !important;
    color: #000000 !important;
    border: none !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s !important;
    text-align: center !important;
}

.ai-editor-generate-btn:hover:not(:disabled) {
    background: #9d7ee8 !important;
}

.ai-editor-generate-btn:disabled {
    background: #333333 !important;
    cursor: not-allowed !important;
    color: #666666 !important;
}

.ai-editor-loading {
    display: none;
    text-align: center;
    margin: 30px 0;
}

.ai-editor-loading.ai-editor-active {
    display: block;
}

.ai-editor-spinner {
    width: 100px;
    height: 100px;
    position: relative;
    margin: 0 auto 15px;
}

.ai-editor-spinner::before,
.ai-editor-spinner::after {
    content: "";
    position: absolute;
    width: 30px;
    height: 30px;
    top: 50%;
    left: 50%;
    animation: up 2.4s cubic-bezier(0, 0, 0.24, 1.21) infinite;
    background: #fff;
}

.ai-editor-spinner::after {
    background: #b296ff;
    top: calc(50% - 30px);
    left: calc(50% - 30px);
    animation-name: down;
}

@keyframes down {
    0%, 100% { transform: none; }
    25% { transform: translateX(100%); }
    50% { transform: translate(100%, 100%); }
    75% { transform: translateY(100%); }
}

@keyframes up {
    0%, 100% { transform: none; }
    25% { transform: translateX(-100%); }
    50% { transform: translate(-100%, -100%); }
    75% { transform: translateY(-100%); }
}

.ai-editor-error {
    background: #fff;
    border: 1px solid #b296ff;
    color: #000;
    padding: 15px;
    margin: 20px 0;
    display: none;
    font-weight: 600;
}

.ai-editor-error.ai-editor-active {
    display: block;
}

.ai-editor-info-box {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #cccccc;
    padding: 15px;
    margin-bottom: 25px;
}

.ai-editor-history {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #333;
}

/* Masonry Layout Styles */
.masonry-layout {
    display: flex;
    gap: 20px;
    width: 100%;
    align-items: flex-start;
}

.masonry-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.masonry-item {
    width: 100%;
}

.ai-editor-generation-row {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 20px;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.ai-editor-result-item img {
    width: 100%;
    height: auto; /* Let images maintain their natural aspect ratio */
    display: block;
    background: #000;
    border: 1px solid #b296ff;
}

.ai-editor-history-title {
    font-size: 20px;
    color: #ffffff;
    margin-bottom: 20px;
    text-align: center;
}

.ai-editor-generation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.ai-editor-generation-time {
    color: #808090;
    font-size: 12px;
    margin-bottom: 5px;
}

.ai-editor-generation-prompt {
    color: #cccccc;
    font-size: 14px;
}

.ai-editor-generation-images {
    display: block;
}

.ai-editor-result-item {
    border: 1px solid #333;
    background: #000;
    position: relative;
    width: 100%;
}

.ai-editor-result-item img {
    width: 100%;
    display: block;
}

.ai-editor-result-actions {
    padding: 10px;
    display: flex;
    gap: 5px;
}

.ai-editor-result-top-actions {
    padding: 8px;
    display: flex;
    gap: 5px;
    border-bottom: 1px solid #333;
    justify-content: center;
}

.ai-editor-icon-btn {
    padding: 8px 12px !important;
    background: #b296ff !important;
    color: #000000 !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 12px !important;
    transition: all 0.2s !important;
    flex: 1;
    font-weight: 600 !important;
    text-align: center !important;
}

.ai-editor-icon-btn:hover {
    background: #9d7ee8 !important;
}

.ai-editor-mini-btn {
    padding: 6px 10px !important;
    background: rgba(178, 150, 255, 0.9) !important;
    color: #000000 !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 11px !important;
    transition: all 0.2s !important;
    font-weight: bold !important;
    text-align: center !important;
}

.ai-editor-mini-btn:hover {
    background: rgba(157, 126, 232, 0.9) !important;
}

.ai-editor-mini-btn.active {
    background: #ffffff !important;
    color: #000000 !important;
}

.ai-editor-selection-canvas-container {
    position: relative;
    display: inline-block;
    margin: 20px 0;
    border: 1px solid #b296ff;
}

.ai-editor-selection-canvas {
    display: block;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
}

.ai-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
}

.ai-editor-modal-content {
    background: #1a1a1a;
    margin-top: 50px;
    border: 1px solid #333;
    padding: 20px 30px 30px 30px;
    max-width: 500px;
    width: 400px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.ai-editor-selection-controls {
    margin: 15px 0;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Payment Modal Styles */
.pricing-options {
    display: grid;
    grid-template-rows: auto auto;
    margin: 20px 0;
}

.pricing-card {
    background: #1a1a1a;
}

.pricing-card h3 {
    font-size: 1.3rem;
    color: #e0e0e0;
    margin-bottom: 15px;
    font-weight: 600;
    text-align: center;
}

.subscription-option {
    background: #1a1a1a;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #3a3a4a;
}

.subscription-option h4 {
    font-size: 1.2rem;
    color: #e0e0e0;
    margin: 0px 0px 8px 0px;
    font-weight: 600;
    text-align: center;
}

.subscription-option .subscription-price {
    font-size: 1.3rem;
    color: #b296ff;
    margin-bottom: 8px;
    font-weight: 700;
    text-align: center;
}

.subscription-option .subscription-credits {
    color: #a0a0a0;
    margin-bottom: 15px;
    font-size: 1.2rem;
    line-height: 1.4;
    text-align: center;
}

.credit-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.credit-grid-large {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.credit-item {
    background: #1a1a1a;
    padding: 12px;
    border: 1px solid #3a3a4a;
    text-align: center;
}

.credit-item .credits {
    font-size: 1.1rem;
    color: #e0e0e0;
    margin-bottom: 5px;
    font-weight: 600;
}

.credit-item .price {
    font-size: 1.1rem;
    color: #b296ff;
    margin-bottom: 8px;
    font-weight: 700;
}

.credit-item .bonus {
    font-size: 0.8rem;
    color: #a0a0a0;
    margin-bottom: 8px;
    line-height: 1.2;
}

.credit-item .ai-editor-btn,
.subscription-option .ai-editor-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.9rem;
}

/* Aspect Ratio Selector */
.ai-editor-aspect-ratio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.ai-editor-aspect-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #888;
}

.ai-editor-aspect-btn:hover {
  border-color: #b296ff;
  color: #b296ff;
}

.ai-editor-aspect-btn.active {
  border-color: #b296ff;
  background: rgba(178, 150, 255, 0.1);
  color: #b296ff;
  border-radius: 0px;
  padding: 5px;
  margin: 0px 10px;
}

.ai-editor-aspect-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-editor-aspect-btn span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

@media (max-width: 800px) {
    .masonry-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .masonry-column {
        display: none;
    }
    
    .masonry-item {
        width: 100%;
    }
    
    .pricing-options {
        grid-template-columns: 1fr !important;
    }
}
