/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f7fa;
    color: #1f2937;
    height: 100vh;
    overflow: hidden;
}

/* Workspace Layout */
.workspace-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Left: Editor Pane --- */
.editor-pane {
    flex: 1.5; /* Takes 60% approx */
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    border-right: 1px solid #e5e7eb;
    position: relative;
    box-shadow: 4px 0 12px rgba(0,0,0,0.02);
    z-index: 10;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.editor-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.main-editor {
    flex: 1;
    width: 100%;
    font-size: 1.125rem;
    line-height: 1.75;
    padding: 1.5rem;
    border: 2px solid #f3f4f6;
    border-radius: 16px;
    outline: none;
    resize: none;
    overflow-y: auto;
    color: #374151;
    transition: all 0.2s ease;
    background-color: #fafafa;
}

.main-editor:focus {
    border-color: #3b82f6;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.main-editor:empty:before {
    content: attr(placeholder);
    color: #9ca3af;
    pointer-events: none;
}

.visualizer-container {
    width: 100%;
    height: 60px;
    margin-top: 1rem;
    background: #f8fafc;
    border-radius: 12px;
    overflow: hidden;
}

#audioVisualizer {
    width: 100%;
    height: 100%;
}

.editor-controls {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    align-items: center;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-size: 1rem;
}

.record-btn {
    flex: 1;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.record-btn:active {
    transform: scale(0.98);
}

.record-btn.recording {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    animation: pulse 1.5s infinite;
}

.undo-btn {
    background-color: #f3f4f6;
    color: #4b5563;
}

.undo-btn:hover {
    background-color: #e5e7eb;
}

.clear-btn {
    background-color: #fee2e2;
    color: #dc2626;
    padding: 0.75rem;
}

.clear-btn:hover {
    background-color: #fecaca;
}

/* --- Right: AI Pane --- */
.ai-pane {
    flex: 1; /* Takes 40% approx */
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.ai-header {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.model-selector-container {
    width: 100%;
}

.model-select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background-color: #fff;
    font-size: 0.9rem;
    color: #334155;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.model-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ai-header h3 {
    font-size: 1.25rem;
    color: #1e293b;
    margin-bottom: 0.25rem;
}

.ai-header p {
    color: #64748b;
    font-size: 0.875rem;
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.style-card {
    background: #fff;
    border-radius: 16px;
    padding: 1.25rem;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    position: relative;
}

.edit-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f1f5f9;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    opacity: 0;
    transition: all 0.2s;
    font-size: 0.9rem;
    z-index: 5;
}

.edit-btn:hover {
    background: #e2e8f0;
    color: #3b82f6;
    transform: scale(1.1);
}

.style-card:hover .edit-btn {
    opacity: 1;
}

.style-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    border-color: #3b82f6;
}

.style-card:active {
    transform: scale(0.98);
}

.card-emoji {
    font-size: 2rem;
    background: #f1f5f9;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-title {
    font-weight: 600;
    color: #334155;
    font-size: 1rem;
}

.custom-prompt-area {
    margin-top: auto;
}

.custom-input {
    width: 100%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.custom-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9ca3af;
    transition: background-color 0.3s;
}

.status-indicator.connected .status-dot {
    background-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Mobile Adaptation */
@media (max-width: 768px) {
    .workspace-container {
        flex-direction: column;
    }

    .editor-pane {
        flex: 1;
        border-right: none;
        padding: 1rem;
    }

    .ai-pane {
        flex: 0 0 auto;
        height: 40vh;
        border-top: 1px solid #e5e7eb;
        padding: 1.5rem;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
        border-radius: 24px 24px 0 0;
    }
    
    .style-grid {
        grid-template-columns: repeat(4, 1fr); /* Horizontal scroll on mobile? Or grid */
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    
    .style-card {
        min-width: 80px;
        padding: 0.75rem;
    }
    
    .card-emoji {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
    
    .card-title {
        font-size: 0.8rem;
    }
}

/* --- Custom Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    margin: 16px 0 24px 0;
    color: #4b5563;
    font-size: 1rem;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.modal-btn.cancel {
    background-color: #f3f4f6;
    color: #4b5563;
}

.modal-btn.cancel:hover {
    background-color: #e5e7eb;
}

.modal-btn.confirm {
    background-color: #ef4444;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.modal-btn.confirm:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
