/**
 * KunaDiet - Custom Styles
 *
 * Solo override non-utility: componenti .kd-*, animazioni custom, Alpine.js,
 * reset, WP overrides. Tutte le utility Tailwind ora arrivano da
 * tailwind-output.css generato con `npm run build:css`.
 */

/* ============================================
   ALPINE.JS CLOAK
   ============================================ */
[x-cloak] { display: none !important; }

/* ============================================
   ANIMAZIONI (tailwindcss-animate compat)
   ============================================ */

/* animate-in: animazione d'ingresso composta da fade + slide */
@keyframes kd-enter {
    from {
        opacity: var(--tw-enter-opacity, 1);
        transform: translate3d(var(--tw-enter-translate-x, 0), var(--tw-enter-translate-y, 0), 0)
                   scale(var(--tw-enter-scale, 1))
                   rotate(var(--tw-enter-rotate, 0));
    }
}

.animate-in {
    animation-name: kd-enter;
    animation-duration: 150ms;
    --tw-enter-opacity: initial;
    --tw-enter-scale: initial;
    --tw-enter-rotate: initial;
    --tw-enter-translate-x: initial;
    --tw-enter-translate-y: initial;
}

.fade-in                 { --tw-enter-opacity: 0; }
.slide-in-from-bottom-4  { --tw-enter-translate-y: 1rem; }
.slide-in-from-bottom-8  { --tw-enter-translate-y: 2rem; }
.slide-in-from-right-4   { --tw-enter-translate-x: 1rem; }
.slide-in-from-right-8   { --tw-enter-translate-x: 2rem; }
.slide-in-from-left-4    { --tw-enter-translate-x: -1rem; }

/* duration-* override per animate-in (la classe Tailwind imposta transition-duration,
   ma animate-in usa animation-duration) */
.animate-in.duration-150 { animation-duration: 150ms; }
.animate-in.duration-200 { animation-duration: 200ms; }
.animate-in.duration-300 { animation-duration: 300ms; }
.animate-in.duration-500 { animation-duration: 500ms; }

/* Named helpers (usati anche in dashboard.js) */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.animate-fade-in  { animation: fadeIn  0.3s ease-out; }
.animate-slide-up { animation: slideUp 0.4s ease-out; }
.animate-scale-in { animation: scaleIn 0.2s ease-out; }

/* Alpine transition helpers */
[x-transition\:enter]       { transition: all 0.3s ease-out; }
[x-transition\:enter-start] { opacity: 0; transform: translateY(8px); }
[x-transition\:enter-end]   { opacity: 1; transform: translateY(0); }
[x-transition\:leave]       { transition: all 0.2s ease-in; }
[x-transition\:leave-start] { opacity: 1; }
[x-transition\:leave-end]   { opacity: 0; }

/* ============================================
   BASE & RESET
   ============================================ */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Scrollbar personalizzata */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================
   DASHBOARD LAYOUT
   ============================================ */
.kd-sidebar            { transition: width 0.3s ease; }
.kd-sidebar-collapsed  { width: 80px; }
.kd-sidebar-expanded   { width: 256px; }

.kd-nav-indicator {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 4px; height: 32px;
    border-radius: 0 9999px 9999px 0;
    background: #10b981;
    transition: all 0.2s ease;
}

/* ============================================
   CARDS & PANELS
   ============================================ */
.kd-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.kd-card:hover { box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); }
.kd-card-interactive:hover { transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1); }

.kd-gradient-card {
    background: linear-gradient(135deg, #10b981, #14b8a6);
    color: white; border: none;
    box-shadow: 0 10px 15px -3px rgb(16 185 129 / 0.3);
}
.kd-dark-card {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: white; border: none;
    box-shadow: 0 10px 15px -3px rgb(15 23 42 / 0.3);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.kd-input {
    width: 100%; padding: 1rem;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 1rem;
    outline: none; transition: all 0.2s ease; font-size: 0.875rem;
}
.kd-input:focus { background: white; border-color: #10b981; box-shadow: 0 0 0 3px rgb(16 185 129 / 0.1); }

.kd-select {
    width: 100%; padding: 1rem;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 1rem;
    outline: none; cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center; background-repeat: no-repeat; background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}
.kd-select:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgb(16 185 129 / 0.1); }

.kd-textarea {
    width: 100%; padding: 1rem;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 1rem;
    outline: none; resize: vertical; min-height: 100px; font-size: 0.875rem;
}
.kd-textarea:focus { background: white; border-color: #10b981; box-shadow: 0 0 0 3px rgb(16 185 129 / 0.1); }

/* ============================================
   BUTTONS
   ============================================ */
.kd-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.25rem; border-radius: 0.75rem;
    font-weight: 600; font-size: 0.875rem; transition: all 0.2s ease;
    cursor: pointer; border: none;
}
.kd-btn:active { transform: scale(0.95); }
.kd-btn-primary       { background: #0f172a; color: white; }
.kd-btn-primary:hover { background: #1e293b; }
.kd-btn-success       { background: #10b981; color: white; box-shadow: 0 4px 6px -1px rgb(16 185 129 / 0.3); }
.kd-btn-success:hover { background: #059669; box-shadow: 0 10px 15px -3px rgb(16 185 129 / 0.3); transform: translateY(-1px); }
.kd-btn-ai            { background: linear-gradient(135deg, #8b5cf6, #d946ef); color: white; box-shadow: 0 4px 6px -1px rgb(139 92 246 / 0.3); }
.kd-btn-ai:hover      { box-shadow: 0 10px 15px -3px rgb(139 92 246 / 0.3); transform: translateY(-1px) scale(1.02); }
.kd-btn-outline       { background: transparent; border: 1px solid #e2e8f0; color: #64748b; }
.kd-btn-outline:hover { background: #f8fafc; border-color: #cbd5e1; color: #334155; }
.kd-btn-ghost         { background: transparent; color: #64748b; }
.kd-btn-ghost:hover   { background: #f1f5f9; color: #334155; }
.kd-btn-danger        { background: #ef4444; color: white; }
.kd-btn-danger:hover  { background: #dc2626; }
.kd-btn:disabled      { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.kd-btn-lg            { padding: 0.875rem 1.75rem; font-size: 1rem; border-radius: 1rem; }

/* ============================================
   PROGRESS BARS
   ============================================ */
.kd-progress { height: 8px; background: #e2e8f0; border-radius: 9999px; overflow: hidden; }
.kd-progress-bar { height: 100%; border-radius: 9999px; transition: width 0.5s ease; }
.kd-progress-emerald .kd-progress-bar { background: #10b981; }
.kd-progress-blue    .kd-progress-bar { background: #3b82f6; }
.kd-progress-red     .kd-progress-bar { background: #ef4444; }
.kd-progress-amber   .kd-progress-bar { background: #f59e0b; }

/* ============================================
   TABLES
   ============================================ */
.kd-table { width: 100%; text-align: left; border-collapse: collapse; }
.kd-table thead tr { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.kd-table th { padding: 1rem 1.5rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; }
.kd-table td { padding: 1rem 1.5rem; font-size: 0.875rem; }
.kd-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.15s ease; }
.kd-table tbody tr:hover { background: #f8fafc; }
.kd-table tbody tr:last-child { border-bottom: none; }

/* ============================================
   LOADING / SKELETON
   ============================================ */
.kd-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.kd-loading-spinner {
    width: 24px; height: 24px;
    border: 3px solid #e2e8f0; border-top-color: #10b981; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   MODAL / OVERLAY
   ============================================ */
.kd-modal-overlay {
    position: fixed; inset: 0;
    background: rgb(15 23 42 / 0.4); backdrop-filter: blur(4px);
    z-index: 50;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.kd-modal {
    background: white; border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    max-height: 85vh; overflow: hidden;
    display: flex; flex-direction: column;
}

/* ============================================
   BADGES / TAGS
   ============================================ */
.kd-badge { display: inline-flex; align-items: center; padding: 0.25rem 0.75rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.kd-badge-emerald { background: #d1fae5; color: #065f46; }
.kd-badge-blue    { background: #dbeafe; color: #1e40af; }
.kd-badge-amber   { background: #fef3c7; color: #92400e; }
.kd-badge-red     { background: #fee2e2; color: #991b1b; }
.kd-badge-slate   { background: #f1f5f9; color: #475569; }

/* ============================================
   AVATAR
   ============================================ */
.kd-avatar { display: flex; align-items: center; justify-content: center; font-weight: 700; border-radius: 9999px; flex-shrink: 0; }
.kd-avatar-sm { width: 32px; height: 32px; font-size: 0.75rem; }
.kd-avatar-md { width: 40px; height: 40px; font-size: 0.875rem; }
.kd-avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.kd-avatar-xl { width: 80px; height: 80px; font-size: 1.5rem; border-radius: 1rem; }

/* ============================================
   WIZARD STEPS
   ============================================ */
.kd-wizard-step { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 1rem; border-radius: 9999px; font-size: 0.875rem; font-weight: 500; transition: all 0.2s ease; }
.kd-wizard-step-active   { background: #0f172a; color: white; }
.kd-wizard-step-inactive { color: #64748b; }
.kd-wizard-step-number   { width: 20px; height: 20px; border-radius: 9999px; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; }

/* ============================================
   LANDING PAGE
   ============================================ */
.kd-hero-gradient { background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 50%, #eff6ff 100%); }
.kd-hero-pattern  { background-image: radial-gradient(circle at 25px 25px, #d1fae5 2px, transparent 0); background-size: 50px 50px; }
.kd-feature-icon  { width: 56px; height: 56px; border-radius: 1rem; display: flex; align-items: center; justify-content: center; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .kd-sidebar { width: 80px !important; }
    .kd-sidebar .kd-sidebar-text { display: none; }
    .kd-table th, .kd-table td { padding: 0.75rem; }
}
@media (max-width: 640px) {
    .kd-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; width: 80px !important; }
    .kd-main-content { margin-left: 80px; }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .kd-sidebar, .kd-no-print { display: none !important; }
    .kd-card { box-shadow: none; border: 1px solid #ccc; }
    body { font-size: 12pt; }
}

/* ============================================
   WORDPRESS OVERRIDES
   ============================================ */

/* Nasconde admin bar e rimuove offset per dashboard e patient portal */
body.kd-dashboard #wpadminbar,
body.kd-patient-portal #wpadminbar {
    display: none !important;
}
body.kd-dashboard,
body.kd-patient-portal {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Rimuove vincoli WP su contenuto */
.kd-app .wp-block-post-content,
.kd-app .entry-content {
    max-width: none;
    padding: 0;
    margin: 0;
}

/* Mobile header offset: gestito con Tailwind utilities (pt-16 md:pt-0) nel template */
