/* ==========================================
   Tizon Health - Master CSS (V46 - Perfect Mobile & Laptop Layout)
   ========================================== */

:root { 
    --dr-green: #2F5233; 
    --dr-gold: #B89742; 
    --dr-light-gold: #fdfaf0; 
    --bg-light: #f8fafc; 
    --text-dark: #1e293b; 
    --danger: #ef4444; 
    --whatsapp: #25d366; 
    --radius: 16px; 
    font-size: 20px; 
}

* { box-sizing: border-box; font-family: 'Segoe UI', Tahoma, sans-serif; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--dr-gold); border-radius: 10px; }

body { margin: 0; padding: 0; background: var(--bg-light); color: var(--text-dark); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

#loginScreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #0f172a 0%, var(--dr-green) 100%); z-index: 999999; display: flex; align-items: center; justify-content: center; padding:20px; }
.login-box { background: white; padding: 40px; border-radius: 20px; box-shadow: 0 30px 60px rgba(0,0,0,0.4); width: 100%; max-width: 450px; text-align: center; border-top: 8px solid var(--dr-gold); display: flex; flex-direction: column; gap: 15px; }

.header { background: var(--dr-green); padding: 15px 25px; display: none; align-items: center; justify-content: space-between; color: white; border-bottom: 4px solid var(--dr-gold); min-height: 80px; }
.app-container { display: none; flex: 1; overflow: hidden; }
.sidebar { width: 280px; background: white; border-inline-end: 1px solid #e2e8f0; padding: 15px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex-shrink:0; }
.content-area { flex: 1; padding: 30px; overflow-y: auto; background: white; overflow-x: hidden; padding-bottom: 120px; }

.tab-btn { background: transparent; border: none; text-align: right; padding: 14px; font-size: 1.1rem; cursor: pointer; border-radius: 10px; color: #475569; font-weight: 600; display: flex; align-items: center; gap: 10px; transition: 0.3s; }
.tab-btn:hover { background: #f1f5f9; color: var(--dr-green); }
.tab-btn.active { background: var(--dr-green); color: white; box-shadow: 0 4px 12px rgba(47,82,51,0.2); }

.card { background: white; border-radius: var(--radius); padding: 25px; margin-bottom: 25px; border: 1px solid #e2e8f0; width: 100%; }
.card-green { border-top: 6px solid var(--dr-green); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.card-gold { border-top: 6px solid var(--dr-gold); background: var(--dr-light-gold); }

.i-box { width: 100%; padding: 14px; border: 2px solid #e2e8f0; border-radius: 10px; font-size: 1.1rem; outline: none; transition: 0.3s; background: #f8fafc; }
.i-box:focus { border-color: var(--dr-green); background: white; }

[contenteditable="true"] { min-height: 150px; background: white; border: 2px solid #e2e8f0; border-radius: 10px; padding: 15px; font-size: 1.2rem; margin-bottom: 15px; line-height: 1.6; outline: none; word-wrap: break-word; }
[contenteditable="true"]:focus { border-color: var(--dr-gold); box-shadow: 0 0 0 3px rgba(184,151,66,0.1); }

.flow-btn { background: var(--dr-green); color: white; border: none; padding: 14px 20px; border-radius: 10px; cursor: pointer; font-weight: bold; font-size: 1.1rem; transition: 0.3s; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;}
.flow-btn:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }

.wa-btn { background: white; color: var(--whatsapp); border: 2px solid var(--whatsapp); border-radius: 10px; padding: 10px 15px; cursor: pointer; font-weight: bold; font-size: 1.1rem; transition: 0.3s; display:inline-flex; align-items:center; justify-content:center; gap:5px; }
.wa-btn:hover { background: var(--whatsapp); color: white; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(37,211,102,0.2); }

.floating-toolbar { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,0.98); backdrop-filter: blur(10px); padding: 10px; border-radius: 50px; border: 2px solid var(--dr-gold); box-shadow: 0 15px 40px rgba(0,0,0,0.2); display: none; gap: 6px; z-index: 100000; align-items: center; flex-wrap: wrap; justify-content: center; width: auto; max-width: 95vw; }
.toolbar-sep { width: 2px; height: 30px; background: #e2e8f0; margin: 0 4px; }
.float-btn { background: white; border: 1px solid #cbd5e1; border-radius: 50%; min-width: 45px; height: 45px; cursor: pointer; font-size: 1.3rem; font-weight: bold; color: #475569; transition: 0.2s; display: flex; align-items: center; justify-content: center; padding:0;}
.float-btn:hover { background: #e2e8f0; color: var(--dr-green); transform: scale(1.1); }
.mic-float { background: #0ea5e9; color: white; border: none; font-size: 1.8rem; min-width: 55px; height: 55px; box-shadow: 0 4px 10px rgba(14,165,233,0.3); }
.mic-float:hover { background: #0284c7; color: white; transform: scale(1.1); }
.mic-float.recording { background: var(--danger); animation: pulse 1.5s infinite; color: white; }
.font-select { height: 40px; padding: 0 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: white; font-size: 1rem; color: #475569; cursor: pointer; outline: none; }

.search-dropdown { display:none; position:absolute; top:110%; left:0; right:0; background:white; border:2px solid var(--dr-gold); z-index:9999; max-height:300px; overflow-y:auto; border-radius:12px; box-shadow:0 15px 35px rgba(0,0,0,0.15); }
.search-dropdown-item { padding:15px 20px; font-size:1.4rem; cursor:pointer; border-bottom:1px solid #f1f5f9; font-weight:bold; color:var(--dr-green); text-align:right; transition:0.2s; }
.search-dropdown-item:hover { background:#f0fdf4; padding-right:25px; }


/* ======================================================== */
/* מנגנון חכם לשורת הקוביות - שבירת שורות אוטומטית כסר מקום */
/* ======================================================== */
.dash-cards-row { 
    display: flex; 
    flex-wrap: wrap; /* הפקודה שגורמת לקוביות לרדת שורה */
    gap: 15px; 
    margin-bottom: 25px; 
    justify-content: flex-start; 
}

.action-card { 
    flex: 1 1 130px; /* מתרחב ומתכווץ עד מינימום 130 פיקסלים */
    max-width: 180px; /* מונע ממנו להימתח מדי במסכי ענק */
    background: white; 
    padding: 20px 10px; 
    border-radius: 15px; 
    text-align: center; 
    cursor: pointer; 
    border: 1px solid #e2e8f0; 
    transition: 0.3s; 
    position: relative; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    min-height: 130px; 
    overflow: hidden; 
}
.action-card b { 
    margin-top: 10px; 
    word-break: break-word; 
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    max-width: 100%; 
    font-size: 0.95rem;
    line-height: 1.2;
}
.action-card:hover { border-color: var(--dr-green); box-shadow: 0 10px 20px rgba(0,0,0,0.05); transform:translateY(-2px); }

.shortcut-controls { display: none; position: absolute; top: -10px; right: -10px; gap: 5px; z-index: 10; }
.action-card.edit-mode { border: 2px dashed var(--danger); background:#fef2f2; }
.action-card.edit-mode .shortcut-controls { display: flex; }

.ctrl-btn { background: white; border-radius: 50%; border: 1px solid #ddd; width: 35px; height: 35px; cursor: pointer; font-size: 1rem; display: flex; align-items: center; justify-content: center; box-shadow:0 4px 6px rgba(0,0,0,0.1); }
.btn-del { color: red; border-color: red; }
.btn-edit { color: #0ea5e9; border-color: #0ea5e9; }

.task-item { display: flex; align-items: center; justify-content: space-between; background: #f8fafc; padding: 15px; border-radius: 12px; margin-bottom: 10px; border: 1px solid #e2e8f0; font-size: 1.1rem; }
.task-done { text-decoration: line-through; color: #94a3b8; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 25px; }
.stat-box { background: white; padding: 25px; border-radius: 16px; border: 1px solid #e2e8f0; text-align: center; cursor: pointer; transition: 0.3s; }
.stat-box:hover { transform: translateY(-5px); border-color: var(--dr-green); box-shadow: 0 10px 20px rgba(0,0,0,0.08); }
.stat-val { font-size: 3rem; font-weight: 900; color: var(--dr-green); }

.crm-item { display: flex; justify-content: space-between; align-items: center; background: white; padding: 20px; border-radius: 12px; margin-bottom: 12px; border: 1px solid #e2e8f0; flex-wrap: wrap; gap: 15px; }
.archive-img { max-height: 180px; max-width: 100%; border-radius: 8px; cursor: pointer; border: 1px solid #e2e8f0; }

.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 20px; }
.ai-box { border: 2px solid var(--dr-green); border-radius: 15px; padding: 20px; background: #fff; }
.ai-display { background: #f0fdf4; min-height: 100px; padding: 15px; border-radius: 10px; font-size: 1.1rem; margin-top: 10px; border:1px solid #bbf7d0; word-wrap: break-word; }

.draggable-list-item { display:flex; justify-content:space-between; align-items:center; padding:12px 15px; border-bottom:1px solid #e2e8f0; background:white; margin-bottom:5px; border-radius:8px; cursor:grab; transition: 0.2s; border: 1px solid transparent; }
.draggable-list-item:hover { background: #f8fafc; border-color: #cbd5e1; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.draggable-list-item:active { cursor: grabbing; background: #f0fdf4; border-color: var(--dr-green); }
.drag-handle { cursor: grab; padding-left: 10px; color: #94a3b8; font-size: 1.2rem; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 100000; align-items: center; justify-content: center; backdrop-filter: blur(4px); padding:20px;}
.modal-card { background: white; width: 100%; max-width: 800px; border-radius: 20px; padding: 30px; position: relative; overflow-y: auto; max-height: 90vh; }

.cloud-badge { position: fixed; top: 20px; left: 20px; padding: 8px 15px; border-radius: 20px; font-weight: bold; font-size: 0.9rem; color: white; z-index: 100; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.cloud-online { background: #10b981; }
.cloud-offline { background: var(--danger); }

#saveIndicator { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--dr-green); color: white; padding: 10px 25px; border-radius: 30px; opacity: 0; transition: 0.3s; z-index: 100001; font-size: 1rem; }
#saveIndicator.show { opacity: 1; }

.admin-only, .admin-only-flex { display: none !important; }
body.is-admin .admin-only { display: block !important; }
body.is-admin .admin-only-flex { display: flex !important; }


/* ==========================================
   הגדרות מתקדמות למובייל וטאבלט - תאימות מלאה!
   ========================================== */
@media(max-width: 850px) { 
    :root { font-size: 16px; } 
    .app-container { flex-direction: column; } 
    .sidebar { width: 100%; flex-direction: row; height: auto; border-bottom: 1px solid #e2e8f0; overflow-x: auto; padding: 10px; } 
    .tab-btn { flex: 0 0 auto; white-space: nowrap; padding: 10px 15px; }
    .content-area { padding: 15px; padding-bottom: 180px; }
    .floating-toolbar { bottom: 10px; width: 98%; padding: 8px; border-radius:15px; flex-wrap:wrap;}
    .float-btn { min-width: 32px; height: 32px; font-size: 1rem; }
    .mic-float { min-width: 40px; height: 40px; font-size: 1.4rem; }
    
    /* סידור קוביות מדויק לטאבלטים ומסכים קטנים */
    .dash-cards-row { justify-content: center; }
    .action-card { flex: 1 1 calc(33% - 15px); max-width: 160px; min-height: 110px; padding: 10px; }
}

@media(max-width: 500px) {
    /* סידור קוביות מושלם לסמארטפונים - 2 בשורה! */
    .action-card { flex: 1 1 calc(50% - 15px); max-width: 100%; min-height: 100px; }
}

@media print { 
    @page { margin: 15mm; size: A4 portrait; }
    html, body { display: block !important; height: auto !important; width: 100% !important; margin: 0 !important; padding: 0 !important; background: white !important; color: black !important; font-size: 14px !important; line-height: 1.5 !important; overflow: visible !important; } 
    body > *:not(#printSection) { display: none !important; } 
    #printSection { display: block !important; position: static !important; width: 100% !important; max-width: 100% !important; margin: 0 auto !important; direction: rtl; overflow: visible !important; } 
    .print-section-block { page-break-inside: avoid; margin-bottom: 20px; width: 100%; display: block; }
    .print-header { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #ccc !important; padding-bottom: 10px; margin-bottom: 20px; }
    .print-header img { max-height: 70px !important; width: auto !important; margin-bottom: 5px; }
    .print-title { font-size: 18px !important; font-weight: bold; color: #000 !important; border-bottom: 2px solid #ccc !important; padding-bottom: 5px; margin-top: 15px; margin-bottom: 10px; page-break-after: avoid; }
    .print-text { font-size: 14px !important; white-space: pre-wrap !important; word-wrap: break-word !important; max-width: 100% !important; display: block; page-break-before: auto; }
    img.archive-img, #printSection img:not(.print-header img) { max-width: 80% !important; height: auto !important; max-height: 300px !important; page-break-inside: avoid; display: block; margin: 10px auto; }
    * { float: none !important; }
}