/**
 * Prompt Engineering Studio - Frontend Styles
 * Professional redesign matching user-manager quality
 */

.pes-generator-wrapper {
    max-width: 1000px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #333;
    padding: 20px 0;
}

/* =================================================================
   HEADER
   ================================================================= */

.pes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.pes-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #23282d;
}

/* =================================================================
   TEMPLATE LIST
   ================================================================= */

.pes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pes-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
}

.pes-item:hover {
    border-color: #ccc;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.pes-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pes-info strong {
    display: block;
    font-size: 15px;
    color: #23282d;
    font-weight: 600;
}

.pes-info code {
    background: #fff;
    padding: 3px 8px;
    border-radius: 2px;
    font-size: 11px;
    border: 1px solid #ddd;
    color: #666;
    font-family: 'Courier New', monospace;
    display: inline-block;
    width: fit-content;
    font-weight: 600;
}

.pes-info small {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}

.pes-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* =================================================================
   EMPTY STATE
   ================================================================= */

.pes-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-style: italic;
    background: #fafafa;
    border-radius: 3px;
    border: 1px dashed #ddd;
}

.pes-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* =================================================================
   BUTTONS
   ================================================================= */

.pes-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border: 1px solid #444;
    background: #3a3a3a;
    color: #fff;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.5;
}

.pes-btn:hover {
    background: #2a2a2a;
    border-color: #222;
    color: #fff;
    text-decoration: none;
}

.pes-btn-primary {
    background: #3a3a3a;
    border-color: #444;
}

.pes-btn-primary:hover {
    background: #2a2a2a;
    border-color: #222;
}

.pes-btn-secondary {
    background: #666;
    border-color: #666;
}

.pes-btn-secondary:hover {
    background: #555;
    border-color: #555;
}

.pes-btn-danger {
    color: #666;
    background: #fff;
    border: 1px solid #ddd;
}

.pes-btn-danger:hover {
    color: #c33;
    border-color: #c33;
}

.pes-btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

.pes-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* =================================================================
   FORMS - PROPER VISUAL HIERARCHY
   ================================================================= */

.pes-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.pes-field-group {
    margin-bottom: 20px;
}

.pes-field-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #23282d;
}

.pes-required {
    color: #c33;
    font-weight: bold;
}

.pes-input,
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 14px;
    background: #fff;
    color: #333;
    transition: all 0.15s ease;
    font-family: inherit;
}

.pes-input:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 0 1px rgba(153, 153, 153, 0.1);
}

.pes-input::placeholder,
input::placeholder,
textarea::placeholder {
    color: #999;
}

textarea.pes-input,
textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.pes-help-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

/* =================================================================
   FORM BUILDER - VISUAL FIELD LIST
   ================================================================= */

#form-builder-test {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 15px;
    min-height: 100px;
    margin-bottom: 15px;
}

#form-builder-test:empty::before {
    content: 'No fields added yet. Click "+ Add Field" below to create your first field.';
    color: #999;
    font-size: 13px;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
}

.field-preview-item {
    background: #fff;
    border: 1px solid #ddd;
    border-left: 4px solid #3a3a3a;
    border-radius: 3px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.15s ease;
}

.field-preview-item:hover {
    border-color: #ccc;
    border-left-color: #2a2a2a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.field-preview-item:last-child {
    margin-bottom: 0;
}

.field-preview-info strong {
    display: block;
    font-size: 15px;
    color: #23282d;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.5;
}

.field-preview-info small {
    display: inline-block;
    font-size: 11px;
    color: #666;
    font-family: 'Courier New', monospace;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 2px;
    border: 1px solid #e0e0e0;
}

.field-preview-info .field-help {
    display: block;
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    margin-top: 8px;
}

.field-preview-actions {
    display: flex;
    gap: 6px;
}

/* Desktop: side-by-side layout */
@media screen and (min-width: 769px) {
    .field-preview-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
    
    .field-preview-info {
        flex: 1;
        min-width: 0;
        padding-right: 15px;
    }
    
    .field-preview-actions {
        flex-shrink: 0;
    }
}

/* Add Field Form */
#add-field-form {
    background: #f9f9f9;
    border: 2px solid #ddd;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 3px;
}

#add-field-form h3 {
    margin: 0 0 20px 0;
    font-size: 17px;
    color: #23282d;
    font-weight: 600;
    padding-bottom: 15px;
    border-bottom: 2px solid #ddd;
}

/* Form sections within add field */
#add-field-form .pes-form-row {
    margin-bottom: 20px;
}

#add-field-form .pes-field-group {
    margin-bottom: 20px;
}

#add-field-form .pes-field-group:last-of-type {
    margin-bottom: 0;
}

#add-field-form .pes-field-group label {
    font-size: 14px;
    font-weight: 600;
    color: #23282d;
    margin-bottom: 6px;
}

#add-field-form input[type="text"],
#add-field-form input[type="number"],
#add-field-form select,
#add-field-form textarea {
    background: #fff;
}

#add-field-form .pes-btn {
    min-width: 120px;
}

/* =================================================================
   FORM CONTAINERS
   ================================================================= */

.pes-generator-form {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 30px;
}

.pes-generator-form h2 {
    margin: 0 0 20px 0;
    font-size: 1.3em;
    color: #23282d;
    font-weight: 600;
}

.pes-form-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =================================================================
   RESULT/OUTPUT DISPLAY
   ================================================================= */

.pes-result-wrapper {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 30px;
    margin-top: 30px;
}

.pes-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.pes-result-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #23282d;
    font-weight: 600;
}

.pes-result-content {
    margin-bottom: 20px;
}

.pes-prompt-output {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 20px;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.8;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-x: auto;
    margin: 0;
}

.pes-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =================================================================
   NOTICES
   ================================================================= */

.pes-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-left: 3px solid #28a745;
    border-radius: 3px;
    padding: 12px 15px;
    margin: 20px 0;
    font-size: 14px;
}

.pes-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 3px solid #dc3545;
    border-radius: 3px;
    padding: 12px 15px;
    margin: 20px 0;
    font-size: 14px;
}

/* =================================================================
   LOADING STATE
   ================================================================= */

.pes-loading {
    text-align: center;
    padding: 40px 20px;
}

.pes-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 3px solid #e0e0e0;
    border-top-color: #3a3a3a;
    border-radius: 50%;
    animation: pes-spin 0.8s linear infinite;
}

@keyframes pes-spin {
    to { transform: rotate(360deg); }
}

.pes-loading-text {
    color: #666;
    font-size: 14px;
}

/* =================================================================
   BACK LINK
   ================================================================= */

.pes-back-link {
    margin-bottom: 15px;
    display: block;
}

.pes-back-link a {
    color: #3a3a3a;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.pes-back-link a:hover {
    color: #2a2a2a;
    text-decoration: underline;
}

/* =================================================================
   RESPONSIVE
   ================================================================= */

@media screen and (max-width: 768px) {
    .pes-generator-wrapper {
        padding: 10px;
        margin: 10px;
    }
    
    .pes-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .pes-form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .pes-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .pes-actions {
        justify-content: flex-start;
    }
    
    .pes-generator-form,
    .pes-result-wrapper {
        padding: 20px;
    }
    
    #add-field-form {
        padding: 15px;
    }
    
    .pes-result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .pes-form-actions,
    .pes-result-actions {
        flex-direction: column;
    }
    
    .pes-btn {
        width: 100%;
        justify-content: center;
    }
}

@media screen and (max-width: 480px) {
    .pes-generator-wrapper {
        margin: 0;
        padding: 5px;
    }
    
    .pes-generator-form,
    .pes-result-wrapper {
        padding: 15px;
    }
    
    .pes-field-group label {
        font-size: 13px;
    }
    
    .pes-input,
    input[type="text"],
    input[type="email"],
    input[type="url"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .pes-info strong {
        font-size: 14px;
    }
    
    .pes-info small {
        font-size: 12px;
    }
    
    .pes-prompt-output {
        font-size: 12px;
        padding: 15px;
    }
}