/**
 * PsicoBio Modern Dashboard CSS
 * Design ispirato a: Notion, Linear, Figma
 */

/* ============================================
   VARIABLES & THEME
   ============================================ */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET & BASE
   ============================================ */
.psicobio-dashboard-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--text-primary);
    line-height: 1.6;
}

.psicobio-dashboard-wrapper * {
    box-sizing: border-box;
}

/* ============================================
   HEADER
   ============================================ */
.psicobio-dashboard-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 48px 32px;
    margin: -20px -20px 32px -20px;
    border-radius: 0 0 24px 24px;
    color: white;
    position: relative;
    overflow: hidden;
}

.psicobio-dashboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="20" height="20" patternUnits="userSpaceOnUse"><path d="M 20 0 L 0 0 0 20" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.5;
}

.psicobio-dashboard-header h1 {
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative;
}

.psicobio-dashboard-header p {
    margin: 0;
    font-size: 16px;
    opacity: 0.9;
    position: relative;
}

/* ============================================
   STATUS BADGE
   ============================================ */
.psicobio-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
    font-size: 14px;
    font-weight: 500;
}

.psicobio-status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.psicobio-status-draft::before { background: var(--text-muted); }
.psicobio-status-pending::before { background: var(--warning); }
.psicobio-status-published::before { background: var(--success); }
.psicobio-status-rejected::before { background: var(--danger); }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ============================================
   MAIN LAYOUT
   ============================================ */
.psicobio-dashboard-content {
    display: grid;
    grid-template-columns: 1fr 500px;
    gap: 32px;
    align-items: start;
}

/* ============================================
   FORM EDITOR
   ============================================ */
.psicobio-editor-column {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

.psicobio-section {
    margin-bottom: 40px;
}

.psicobio-section:last-child {
    margin-bottom: 0;
}

.psicobio-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.psicobio-section h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 2px;
}

/* ============================================
   FORM GROUPS
   ============================================ */
.psicobio-form-group {
    margin-bottom: 24px;
}

.psicobio-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.psicobio-form-group label .required {
    color: var(--danger);
    margin-left: 2px;
}

.psicobio-form-group input[type="text"],
.psicobio-form-group input[type="email"],
.psicobio-form-group input[type="url"],
.psicobio-form-group textarea,
.psicobio-form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition);
    outline: none;
}

.psicobio-form-group input:focus,
.psicobio-form-group textarea:focus,
.psicobio-form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.psicobio-form-group textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.psicobio-form-group small {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* URL Input with Prefix */
.url-input-wrapper {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition);
}

.url-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.url-prefix {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    border-right: 1px solid var(--border);
}

.url-input-wrapper input {
    flex: 1;
    border: none !important;
    box-shadow: none !important;
    padding: 12px 16px;
}

/* ============================================
   LINKS SECTION
   ============================================ */
.psicobio-link-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    transition: var(--transition);
}

.psicobio-link-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.psicobio-link-item input {
    margin: 0;
    font-size: 14px;
}

.psicobio-link-item button {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 20px;
    line-height: 1;
}

.psicobio-link-item button:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    transform: scale(1.05);
}

/* ============================================
   TEMPLATES GRID
   ============================================ */
.psicobio-templates {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.template-item {
    cursor: pointer;
    padding: 16px;
    border: 2px solid var(--border-light);
    border-radius: var(--radius);
    background: var(--bg-primary);
    transition: var(--transition);
    text-align: center;
}

.template-item:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.template-item.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: var(--shadow);
}

.template-preview {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    display: flex;
    gap: 4px;
    padding: 8px;
}

.template-preview > div {
    flex: 1;
    border-radius: 4px;
}

.template-item h4 {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.template-item p {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */
.psicobio-actions {
    display: flex;
    gap: 12px;
    padding-top: 32px;
    border-top: 1px solid var(--border-light);
    margin-top: 32px;
}

.button-primary,
.button-secondary {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.button-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.button-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.button-primary:active {
    transform: translateY(0);
}

.button-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}

.button-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

/* ============================================
   LIVE PREVIEW
   ============================================ */
.psicobio-live-preview {
    position: sticky;
    top: 32px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    max-height: calc(100vh - 64px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.psicobio-live-preview h2 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.psicobio-live-preview .description {
    margin: 0 0 20px;
    font-size: 13px;
    color: var(--text-muted);
}

#live-preview-container {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#live-preview-container::-webkit-scrollbar {
    width: 8px;
}

#live-preview-container::-webkit-scrollbar-track {
    background: transparent;
}

#live-preview-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

#live-preview-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.preview-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ============================================
   VALIDATION ERRORS
   ============================================ */
.field-error {
    border-color: var(--danger) !important;
    background: rgba(239, 68, 68, 0.05) !important;
    animation: shake 0.3s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.error-message {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--danger);
    border-radius: 4px;
    color: var(--danger);
    font-size: 13px;
    font-weight: 500;
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   NOTICES
   ============================================ */
.psicobio-notice {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: slideDown 0.3s;
}

.psicobio-notice::before {
    content: '';
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.psicobio-notice-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #065f46;
}

.psicobio-notice-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #92400e;
}

.psicobio-notice-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #991b1b;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .psicobio-dashboard-content {
        grid-template-columns: 1fr;
    }
    
    .psicobio-live-preview {
        position: relative;
        top: 0;
        max-height: 600px;
    }
}

@media (max-width: 768px) {
    .psicobio-dashboard-header {
        padding: 32px 20px;
        margin: -20px -20px 24px -20px;
    }
    
    .psicobio-dashboard-header h1 {
        font-size: 24px;
    }
    
    .psicobio-editor-column {
        padding: 20px;
    }
    
    .psicobio-actions {
        flex-direction: column;
    }
    
    .psicobio-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .psicobio-link-item {
        grid-template-columns: 1fr;
    }
    
    .psicobio-templates {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.psicobio-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
}

.psicobio-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   FILE UPLOAD
   ============================================ */
.file-upload-wrapper {
    position: relative;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.file-upload-button:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--primary);
}

.profile-image-preview {
    margin-top: 12px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border);
    box-shadow: var(--shadow);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-muted {
    color: var(--text-muted);
}

.text-small {
    font-size: 13px;
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
