/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* App Layout */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2196f3, #1976d2);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.install-button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.install-button:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Content */
.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Configuration Panel */
.config-panel {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: fit-content;
}

.config-panel h2 {
    margin-bottom: 1.5rem;
    color: #1976d2;
    font-size: 1.25rem;
}

.config-group {
    margin-bottom: 1.5rem;
}

.config-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.config-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s;
}

.config-select:focus {
    outline: none;
    border-color: #2196f3;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.radio-label:hover {
    background-color: #f5f5f5;
}

.radio-label input[type="radio"] {
    margin-right: 0.5rem;
    accent-color: #2196f3;
}

.file-input {
    width: 100%;
    padding: 0.5rem;
    border: 2px dashed #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-input:hover {
    border-color: #2196f3;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.primary-button, .secondary-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.primary-button {
    background: #2196f3;
    color: white;
}

.primary-button:hover:not(:disabled) {
    background: #1976d2;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(33,150,243,0.3);
}

.secondary-button {
    background: #4caf50;
    color: white;
}

.secondary-button:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(76,175,80,0.3);
}

.primary-button:disabled, .secondary-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.primary-button:active:not(:disabled),
.secondary-button:active:not(:disabled) {
    transform: translateY(0);
}

/* Share button specific styling */
#share-btn {
    background: #ff9800;
}

#share-btn:hover:not(:disabled) {
    background: #f57c00;
    box-shadow: 0 4px 8px rgba(255,152,0,0.3);
}

#share-btn:disabled {
    background: #ccc;
}

/* Preview Panel */
.preview-panel {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-panel h2 {
    margin-bottom: 1.5rem;
    color: #1976d2;
    font-size: 1.25rem;
}

.preview-container {
    position: relative;
    width: 100%;
    height: 600px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-x pan-y;
}

.preview-canvas {
    display: block;
    margin: 0 auto;
    background: white;
    border: 1px solid #ddd;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.preview-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 1.1rem;
    background: white;
    pointer-events: none;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Message Overlays */
.error-message, .success-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.error-content, .success-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.error-content h3 {
    color: #f44336;
    margin-bottom: 1rem;
}

.success-content h3 {
    color: #4caf50;
    margin-bottom: 1rem;
}

.error-close, .success-close {
    margin-top: 1.5rem;
    padding: 0.5rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.error-close {
    background: #f44336;
    color: white;
}

.success-close {
    background: #4caf50;
    color: white;
}

.error-close:hover {
    background: #d32f2f;
}

.success-close:hover {
    background: #45a049;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Focus Styles for Accessibility */
button:focus, select:focus, input:focus {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .app-header, .config-panel, .action-buttons {
        display: none;
    }
    
    .app-main {
        grid-template-columns: 1fr;
    }
    
    .preview-panel {
        box-shadow: none;
        border: none;
    }
}