/* css/style.css - העיצוב המלא והנקי (אתר ציבורי + צ'אט + פרופיל) */

@import url('https://fonts.googleapis.com/css2?family=Varela+Round&display=swap');

:root {
    --bg-color: #E0F7FA;      /* רקע תכלת עדין */
    --card-bg: #ffffff;
    --text-color: #37474F;
    --primary: #FF7043;       /* כתום שמח */
    --secondary: #00BCD4;     /* תכלת חזק */
    --accent: #AB47BC;        /* סגול */
    --radius: 25px;           /* פינות עגולות מאוד */
    --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

body {
    font-family: 'Varela Round', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { text-decoration: none; color: inherit; transition: 0.3s; }

/* --- כותרת ראשית (Navbar) --- */
.main-navbar {
    background: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

.logo-area {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon { font-size: 1.4em; animation: bounce 2s infinite; }

.user-area { display: flex; gap: 10px; align-items: center; }

/* כפתורים עגולים ויפים */
.btn-pill {
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.95em;
    border: 2px solid transparent;
    transition: 0.3s;
    display: inline-block;
    cursor: pointer;
    text-decoration: none;
}

.btn-pill:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }

.btn-login { background: #E0F2F1; color: #00695C; }
.btn-signup { background: var(--primary); color: white; }
.btn-profile { background: #F3E5F5; color: var(--accent); }
.btn-admin { background: #FFF3E0; color: #E65100; border: 2px solid #FFE0B2; }

/* התראות (נקודה אדומה) */
.notification-badge-global {
    background-color: #ff4d4f;
    color: white;
    font-size: 0.75em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-right: 5px;
    vertical-align: middle;
}

/* --- אזור תוכן ראשי --- */
.main-container {
    max-width: 1100px;
    margin: 30px auto;
    width: 90%;
    flex: 1;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
}

.page-header h1 {
    font-size: 2.8em;
    color: var(--secondary);
    text-shadow: 3px 3px 0px white;
    margin-bottom: 10px;
}

.subtitle { font-size: 1.2em; color: #78909C; }

/* --- גריד קטגוריות וספרים --- */
.grid-container, .categories-grid, .books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 30px;
}

/* כרטיסיה כללית */
.card, .category-card, .book-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
    border-bottom: 6px solid #eee;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}

.category-card { border-bottom-color: var(--secondary); }
.cat-icon { font-size: 4em; margin-bottom: 15px; display: block; }
.cat-title { font-size: 1.4em; font-weight: bold; color: var(--text-color); margin-bottom: 10px; }

.book-card { border-bottom-color: var(--primary); padding: 0; }
.book-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 4px solid #f0f0f0;
}
.book-info { padding: 20px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.book-title { font-size: 1.3em; font-weight: bold; color: #FF7043; margin-bottom: 10px; }

.card:hover, .category-card:hover, .book-card:hover { transform: translateY(-10px); }

/* תגים על ספרים */
.badge {
    display: inline-block;
    padding: 5px 12px; border-radius: 15px;
    font-size: 0.8em; font-weight: bold;
    margin-top: 5px;
}
.badge-public { background: #C8E6C9; color: #2E7D32; }
.badge-registered { background: #FFF9C4; color: #FBC02D; }
.badge-password { background: #FFCCBC; color: #D84315; }

/* --- לוח קריאה (סליידר אופקי) --- */
.continue-reading-list {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding: 10px 5px 25px 5px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.reading-card {
    min-width: 280px;
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    border: 1px solid #eee;
    transition: 0.3s;
}
.reading-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.reading-card img { width: 60px; height: 80px; object-fit: cover; border-radius: 10px; }

.reading-info { flex: 1; }
.reading-info h4 { margin: 0 0 5px 0; font-size: 1.1em; color: var(--text-color); }
.reading-info span { font-size: 0.9em; color: #888; }

.card-actions { position: absolute; top: 10px; left: 10px; display: flex; gap: 5px; }
.action-mini-btn {
    background: #F5F5F5; border: none; border-radius: 50%;
    width: 25px; height: 25px; font-size: 0.8em;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    color: #777; transition: 0.2s;
}
.btn-hide:hover { background: #FFCCBC; color: #D84315; }
.btn-remove:hover { background: #FFCDD2; color: #C62828; }

.continue-reading-list::-webkit-scrollbar { height: 8px; }
.continue-reading-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.continue-reading-list::-webkit-scrollbar-track { background: transparent; }

/* --- דף קריאה (Story Reader) --- */
.book-viewer {
    width: 100%;
    max-width: 800px;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 20px auto;
}

.cover-mode { 
    text-align: center; background: #FFF3E0; flex-grow: 1; padding: 40px; 
    display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.cover-img { max-width: 80%; border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.1); margin-bottom: 20px; }

.page-mode { display: flex; flex-direction: column; height: 100%; flex-grow: 1; }
.page-text { 
    padding: 30px 40px; font-size: 1.4em; line-height: 1.9; 
    background: white; flex: 1; overflow-y: auto; color: #455A64; position: relative; 
}
.page-text img { max-width: 100%; height: auto; border-radius: 15px; margin: 15px 0; display: block; }

.audio-player-container { 
    background: #FFF3E0; padding: 15px 20px; border-bottom: 2px solid #FFCCBC; 
    display: flex; align-items: center; justify-content: space-between; gap: 15px;
}
.audio-select { 
    padding: 8px; border-radius: 20px; border: 1px solid #FFAB91; 
    background: white; font-family: inherit; font-size: 0.9em; flex: 1;
}

.nav-bar { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: #FF7043; }
.nav-btn { 
    background: white; border: none; padding: 10px 20px; border-radius: 30px; 
    cursor: pointer; font-weight: bold; text-decoration: none; color: #D84315; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.icon-btn { background: none; border: none; font-size: 1.8em; cursor: pointer; margin: 0 5px; transition: 0.2s; }
.icon-btn:hover { transform: scale(1.2); }
.fav-btn.active { filter: drop-shadow(0 0 5px red); }

/* --- דפי כניסה / הרשמה / פרופיל --- */
.auth-box {
    background: white; max-width: 400px; margin: 50px auto; padding: 40px; 
    border-radius: var(--radius); text-align: center; box-shadow: var(--shadow);
}

.auth-input {
    width: 100%; padding: 15px; margin-bottom: 15px; border: 2px solid #eee; 
    border-radius: 15px; font-size: 1.1em; box-sizing: border-box;
}
.auth-input:focus { border-color: var(--secondary); outline: none; }

/* כפתור העלאת תמונה מעוצב */
.file-upload-wrapper {
    position: relative; overflow: hidden; display: inline-block; width: 100%;
}
.file-upload-wrapper input[type=file] {
    font-size: 100px; position: absolute; left: 0; top: 0; opacity: 0; cursor: pointer;
}
.custom-file-btn {
    background: #ECEFF1; color: #455A64; border: 2px dashed #CFD8DC; 
    padding: 15px; border-radius: 15px; text-align: center; display: block; 
    cursor: pointer; font-weight: bold; transition: 0.3s;
}
.custom-file-btn:hover { background: #E3F2FD; border-color: var(--secondary); color: var(--secondary); }

/* קופסת מידע (הגדרות) */
.info-box {
    background: #FFF8E1; border: 1px solid #FFECB3; color: #5D4037; 
    padding: 20px; border-radius: 15px; margin-bottom: 25px;
}

/* --- דף הצ'אט --- */
.chat-layout {
    display: flex; max-width: 1200px; margin: 20px auto; width: 95%; 
    background: white; border-radius: 25px; box-shadow: 0 10px 30px rgba(0,0,0,0.05); 
    overflow: hidden; height: calc(100vh - 100px);
}
.contacts-list { width: 280px; background: #FFF; border-left: 2px solid #F0F0F0; overflow-y: auto; }
.contacts-header { padding: 20px; color: var(--accent); font-weight: bold; font-size: 1.1em; border-bottom: 2px solid #F0F0F0; background: white; position: sticky; top: 0; z-index: 5; }
.contact-item { padding: 15px; cursor: pointer; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid #FAFAFA; transition: 0.2s; position: relative; }
.contact-item:hover { background: #F3E5F5; }
.contact-item.active { background: #E1BEE7; margin: 5px; border-radius: 15px; }
.contact-item.has-unread { background-color: #fff8f8; }

.chat-area { flex: 1; display: flex; flex-direction: column; background: #FAFAFA; position: relative; }
.chat-header-bar { background: rgba(255,255,255,0.9); padding: 15px 20px; border-bottom: 1px solid #eee; color: var(--accent); font-weight: bold; backdrop-filter: blur(5px); display: flex; justify-content: space-between; align-items: center; }
.messages-container { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; }
.msg { max-width: 70%; padding: 12px 20px; border-radius: 20px; font-size: 1.05em; position: relative; word-wrap: break-word; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.msg-mine { align-self: flex-end; background: #E1BEE7; color: #4A148C; border-bottom-left-radius: 20px; border-bottom-right-radius: 5px; }
.msg-theirs { align-self: flex-start; background: #FFFFFF; color: #37474F; border-bottom-left-radius: 5px; border-bottom-right-radius: 20px; }
.input-area { padding: 15px; background: white; display: flex; align-items: center; gap: 10px; border-top: 2px solid #F0F0F0; }
.chat-input { flex: 1; padding: 15px; border-radius: 30px; border: 2px solid #E0E0E0; outline: none; font-size: 1.1em; }
.send-btn { background: var(--primary); color: white; border: none; width: 50px; height: 50px; border-radius: 50%; cursor: pointer; font-size: 1.5em; display: flex; justify-content: center; align-items: center; box-shadow: 0 4px 10px rgba(255, 112, 67, 0.3); }
.avatar { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; border: 3px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.status-dot { width: 12px; height: 12px; background: #ddd; border-radius: 50%; border: 2px solid white; position: absolute; bottom: 5px; right: 15px; }
.status-dot.online { background: #66BB6A; }

/* רספונסיביות למובייל */
@media (max-width: 600px) {
    .main-navbar { flex-direction: column; gap: 15px; text-align: center; }
    .user-area { width: 100%; justify-content: center; flex-wrap: wrap; }
    .page-header h1 { font-size: 2em; }
    .page-text { padding: 20px; font-size: 1.2em; }
    
    /* צ'אט במובייל */
    .chat-layout { flex-direction: column; margin: 0; width: 100%; height: calc(100vh - 60px); border-radius: 0; }
    .contacts-list { width: 100%; height: 100px; display: flex; overflow-x: auto; border-bottom: 2px solid #eee; border-left: none; }
    .contact-item { flex-direction: column; padding: 10px; width: 70px; text-align: center; border:none; justify-content: center; }
    .contact-name { font-size: 0.8em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 100%; }
    .chat-area { height: calc(100% - 100px); }
}

@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* --- מצב לילה (Dark Mode) - מרוכז בסוף --- */
body.dark-mode { background-color: #263238; color: #ECEFF1; }

body.dark-mode .card, 
body.dark-mode .auth-box, 
body.dark-mode .main-navbar, 
body.dark-mode .chat-layout,
body.dark-mode .book-viewer,
body.dark-mode .reading-card { 
    background-color: #37474F; 
    color: #ECEFF1; 
    border-bottom-color: #455A64;
    border-color: #455A64;
    box-shadow: none;
}

body.dark-mode .page-text { background-color: #37474F; color: #ECEFF1; }

body.dark-mode input[type="text"], 
body.dark-mode input[type="email"], 
body.dark-mode input[type="password"], 
body.dark-mode input[type="date"], 
body.dark-mode select, 
body.dark-mode textarea,
body.dark-mode .auth-input,
body.dark-mode .chat-input {
    background-color: #455A64;
    border-color: #546E7A;
    color: white;
}

body.dark-mode .info-box {
    background-color: #424242; border-color: #616161; color: #ECEFF1;
}

body.dark-mode .custom-file-btn {
    background: #455A64; border-color: #607D8B; color: #B0BEC5;
}
body.dark-mode .custom-file-btn:hover { background: #546E7A; border-color: var(--secondary); }

body.dark-mode label { color: #B0BEC5; }
body.dark-mode h1, body.dark-mode h2 { color: #80CBC4; text-shadow: none; }

/* --- מערכת סטטוסים חכמה --- */

/* הנקודה הצבעונית ליד השם */
.user-status-indicator {
    width: 12px; height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    border: 2px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: 0.3s;
    position: relative;
}

/* צבעי הסטטוסים */
.status-online { background-color: #4CAF50; } /* ירוק - פנוי */
.status-busy   { background-color: #F44336; } /* אדום - עסוק */
.status-away   { background-color: #FF9800; } /* כתום - לא נמצא */
.status-dnd    { 
    background-color: #D32F2F; /* אדום כהה */
    background-image: linear-gradient(45deg,rgba(255,255,255,0.4) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0.4) 75%, transparent 75%, transparent);
    background-size: 4px 4px; /* טקסטורה של "אין כניסה" */
}

/* התפריט שנפתח */
.status-dropdown {
    display: none; /* מוסתר כברירת מחדל */
    position: absolute;
    top: 50px; left: 20px; /* מיקום יחסי ליוזר */
    background: white;
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    z-index: 2000;
    width: 160px;
    text-align: right;
    border: 1px solid #eee;
    animation: popIn 0.2s ease;
}

.status-dropdown.show { display: block; }

.status-option {
    display: flex; align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 10px;
    transition: 0.2s;
    color: #555;
    font-size: 0.95em;
}

.status-option:hover { background-color: #F5F5F5; }
.status-option .dot { width: 10px; height: 10px; border-radius: 50%; margin-left: 10px; }

/* התאמה למצב לילה */
body.dark-mode .status-dropdown { background-color: #37474F; border-color: #546E7A; }
body.dark-mode .status-option { color: #ECEFF1; }
body.dark-mode .status-option:hover { background-color: #455A64; }