/* BASE RESET & GLOBAL SECURITY */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent !important; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }

body { background-color: #cbd5e1; display: flex; justify-content: center; height: 100vh; height: 100dvh; overflow: hidden; }
.mobile-wrapper { width: 100%; max-width: 414px; background-color: #f1f5f9; display: flex; flex-direction: column; height: 100%; position: relative; box-shadow: 0 0 30px rgba(0,0,0,0.15); overflow: hidden; }

.header-bg { background: linear-gradient(135deg, #991b1b 0%, #dc2626 100%); color: white; flex-shrink: 0; z-index: 10; position: relative; box-shadow: 0 2px 10px rgba(0,0,0,0.1); padding: 15px 20px;}
.header-bg-large { padding-bottom: 25px; border-bottom-left-radius: 25px; border-bottom-right-radius: 25px; }
.screen { display: none; flex-direction: column; height: 100%; background: #f8fafc; }
.screen.active { display: flex; }

/* AUTHENTICATION */
.auth-content { padding: 30px 20px; margin-top: -20px; position: relative; z-index: 11; flex: 1; overflow-y:auto; display:flex; flex-direction:column; justify-content:center;}
.auth-card { background: white; border-radius: 24px; padding: 30px 25px; box-shadow: 0 10px 30px rgba(153, 27, 27, 0.08); }
.input-group { margin-bottom: 18px; }
.input-group label { font-size: 13px; color: #64748b; font-weight: 600; display:block; margin-bottom:6px;}
.input-group input { width: 100%; padding: 14px; border: 1px solid #e2e8f0; border-radius: 12px; outline: none; transition: 0.3s; background:#f8fafc; font-size:14px;}
.input-group input:focus { border-color: #dc2626; background:white; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }
.btn-primary { width: 100%; padding: 15px; background: #dc2626; color: white; border: none; border-radius: 12px; font-weight: 600; font-size:15px; cursor: pointer; transition: 0.2s; box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);}
.btn-primary:active { transform: scale(0.98); background: #b91c1c; }
.switch-auth { text-align: center; margin-top: 20px; font-size: 13px; color: #64748b; cursor: pointer;}
.switch-auth span { color: #dc2626; font-weight: bold;}

/* BERANDA */
.header-top { display: flex; justify-content: space-between; align-items: center; }
.contact-list { padding: 15px; overflow-y: auto; flex: 1; padding-bottom: 90px; } 
.contact-item { background: white; border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: center; gap: 15px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); cursor: pointer; transition: 0.2s; border: 1px solid transparent;}
.contact-item:active { background: #fef2f2; border-color: #fecaca; transform: scale(0.99);}

.c-avatar { width: 48px; height: 48px; background: #fee2e2; color: #dc2626; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 18px; flex-shrink: 0; overflow: hidden; border: 2px solid white; box-shadow: 0 2px 5px rgba(0,0,0,0.1);}
.c-avatar img { width: 100%; height: 100%; object-fit: cover; display: block;}
.c-info { flex: 1; overflow: hidden; }
.c-info-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.c-info h4 { font-size: 15px; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600;}
.c-time { font-size: 11px; color: #94a3b8; font-weight: 500; }
.c-info p { font-size: 13px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display:flex; justify-content:space-between; align-items:center;}
.badge-notif { background: #dc2626; color: white; font-size: 11px; font-weight: bold; padding: 4px 8px; border-radius: 12px; display: none; box-shadow: 0 2px 5px rgba(220, 38, 38, 0.3); }
.badge-mention { background: #fef08a; color: #b45309; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 8px; margin-right: 5px; flex-shrink: 0;}
.fab-btn { position: absolute; bottom: 30px; right: 20px; width: 60px; height: 60px; background: #dc2626; color: white; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 24px; box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4); cursor: pointer; border: none; z-index: 50; transition:0.2s;}
.fab-btn:active { transform: scale(0.90); }

/* CHAT SCREEN */
.chat-header { display: flex; align-items: center; gap: 12px; }
.btn-back { background:transparent; border:none; color:white; font-size:20px; cursor:pointer; padding:5px; }
#chat-box { flex: 1; padding: 20px 15px; overflow-y: auto; background-color: #e2e8f0; position: relative; }
#chat-blur-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(226, 232, 240, 0.7); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 25; display: none; transition: 0.2s; }
.msg-wrapper { margin-bottom: 15px; display: flex; flex-direction: column; position: relative; transition: 0.2s;}
.msg-wrapper.highlighted { z-index: 30; }

.msg { padding: 10px 16px; border-radius: 18px; font-size: 14.5px; line-height: 1.5; word-wrap: break-word; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.04); cursor: pointer; position: relative; white-space: pre-wrap; }
.msg-saya { background-color: #dc2626; color: white; border-top-right-radius: 4px; }
.msg-teman { background-color: white; color: #1e293b; border-top-left-radius: 4px; }
.msg-row { display: flex; align-items: center; gap: 5px; max-width: 88%; }
.btn-msg-opt { background: transparent; border: none; color: #94a3b8; font-size: 16px; cursor: pointer; padding: 5px; opacity: 0; transition: 0.2s;}
.msg-wrapper:hover .btn-msg-opt { opacity: 1; }
.msg a { text-decoration: underline; font-weight: 500; cursor: pointer; }
.msg-saya a { color: #fecaca; } .msg-teman a { color: #2563eb; } 
.mention-tag { color: #2563eb; font-weight: 700; cursor: pointer; }
.msg-saya .mention-tag { color: #fef08a; } 

.sender-info { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; align-self: flex-start; margin-left: 5px; transition: 0.2s;}
.sender-info:active { opacity: 0.6; }
.sender-name { font-size: 12px; color: #64748b; font-weight: 600; }
.msg-avatar-mini { width: 18px; height: 18px; border-radius: 50%; overflow: hidden; background: #fee2e2; color: #dc2626; display: flex; justify-content: center; align-items: center; font-size: 9px; font-weight: bold; flex-shrink: 0;}
.msg-avatar-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg-info-row { display: flex; justify-content: flex-end; align-items: center; gap: 6px;}
.msg-time-txt { font-size: 10.5px; font-weight: 500; opacity: 0.8; }
.msg-saya .msg-time-txt { color: rgba(255,255,255,0.8); }
.msg-teman .msg-time-txt { color: #94a3b8; }
.msg-ticks { font-size: 11px; flex-shrink: 0;}
.tick-unread { color: rgba(255,255,255,0.6); }
.tick-read { color: #38bdf8; }

/* MEDIA */
.chat-media { width: 100%; max-width: 250px; border-radius: 12px; object-fit: cover; cursor: pointer; pointer-events: auto; }
.media-grid { display: grid; gap: 3px; border-radius: 14px; overflow: hidden; margin-bottom: 4px; width: 100%; max-width: 260px; background: rgba(0,0,0,0.05);}
.media-grid-1 { grid-template-columns: 1fr; }
.media-grid-1 img { width: 100%; height: auto; max-height: 280px; object-fit: cover; }
.media-grid-2 { grid-template-columns: 1fr 1fr; }
.media-grid-2 img { width: 100%; height: 140px; object-fit: cover; }
.media-grid-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 140px 100px; }
.media-grid-3 img:first-child { grid-column: span 2; width: 100%; height: 100%; object-fit: cover;}
.media-grid-3 img { width: 100%; height: 100%; object-fit: cover;}
.media-grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 130px 130px; }
.media-grid-4 img, .media-grid-4 .media-more { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-more { position: relative; cursor: pointer; }
.media-more::after { content: '+' attr(data-count); position: absolute; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.5); color:white; display:flex; justify-content:center; align-items:center; font-size:26px; font-weight:bold; }

.quote-box { background: rgba(0,0,0,0.05); border-left: 4px solid #fca5a5; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; cursor: pointer; }
.msg-teman .quote-box { background: #f1f5f9; border-left: 4px solid #dc2626; }
.quote-name { font-weight: 700; margin-bottom: 2px; color: inherit; }
.quote-text { opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px;}

.msg-options { display: none; position: absolute; background: white; box-shadow: 0 10px 40px rgba(0,0,0,0.2); border-radius: 16px; z-index: 35; padding: 8px 0; min-width: 170px; }
.msg-options.active { display: block; animation: popMenu 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popMenu { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.opt-btn { width: 100%; text-align: left; background: none; border: none; padding: 14px 20px; font-size: 14px; font-weight: 500; color: #334155; cursor: pointer; display: flex; gap: 12px; align-items: center; transition: 0.2s;}
.opt-btn i { font-size: 16px; width: 16px; text-align: center; color: #64748b;}
.opt-btn:hover, .opt-btn:active { background: #f8fafc; }
.opt-btn.danger { color: #dc2626; } .opt-btn.danger i { color: #dc2626; }

#reply-banner { display: none; background: #f8fafc; padding: 12px 18px; border-left: 4px solid #dc2626; border-top-left-radius: 16px; border-top-right-radius: 16px; position: relative; border-bottom: 1px solid #e2e8f0; margin: 0 10px;}
#reply-banner-name { font-size: 13px; font-weight: 700; color: #dc2626; margin-bottom: 2px;}
#reply-banner-text { font-size: 13px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90%;}
.btn-close-reply { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #94a3b8; font-size: 20px; cursor: pointer; }

#mention-popup { position: absolute; bottom: 100%; left: 15px; background: white; width: 250px; max-height: 200px; overflow-y: auto; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.15); display: none; z-index: 30; border: 1px solid #e2e8f0; padding: 5px; margin-bottom: 10px; }
.mention-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: 0.2s; font-size: 14px; font-weight: 500; color: #1e293b;}
.mention-item:hover, .mention-item:active { background: #f1f5f9; }

#input-area { background: white; padding: 12px 15px; display: flex; align-items: flex-end; gap: 10px; z-index: 20; border-top: 1px solid #e2e8f0; flex-shrink: 0; position: relative;}
.btn-action { background: transparent; color: #94a3b8; border: none; font-size: 24px; cursor: pointer; padding: 6px; margin-bottom: 3px; transition: 0.2s;}
.btn-action:active { color: #dc2626; transform: scale(0.9); }
#message { flex: 1; padding: 12px 16px; border-radius: 20px; border: 1px solid #cbd5e1; background-color: #f8fafc; font-size: 15px; outline: none; transition: border-color 0.3s; resize: none; overflow-y: auto; min-height: 48px; max-height: 120px; line-height: 1.4; }
#message:focus { border-color: #dc2626; background: white; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);}
#btn-send { background: #dc2626; color: white; border: none; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; font-size: 18px; display:flex; justify-content:center; align-items:center; margin-bottom: 1px; box-shadow: 0 4px 10px rgba(220, 38, 38, 0.3); transition: 0.2s; flex-shrink:0;}
#btn-send:active { transform: scale(0.9); background: #b91c1c; }

#emoji-picker { display: none; position: absolute; bottom: 85px; left: 15px; background: white; border-radius: 20px; padding: 15px; width: calc(100% - 30px); box-shadow: 0 10px 40px rgba(0,0,0,0.15); grid-template-columns: repeat(8, 1fr); gap: 12px; max-height: 250px; overflow-y: auto; z-index: 21; border: 1px solid #e2e8f0; }
.emoji-item { font-size: 24px; cursor: pointer; text-align: center; transition: transform 0.1s;}
.emoji-item:active { transform: scale(1.3); }

/* BOTTOM MODALS (NOTA) */
.nota-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.6); z-index: 100; opacity: 0; pointer-events: none; display: flex; justify-content: center; align-items: flex-end; transition: 0.3s; backdrop-filter: blur(2px);}
.nota-overlay.active { opacity: 1; pointer-events: auto; }
.nota-sheet { width: 100%; max-width: 414px; background: white; border-top-left-radius: 30px; border-top-right-radius: 30px; padding: 25px 25px 40px 25px; transform: translateY(100%); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1); display: flex; flex-direction: column; max-height: 85vh;}
.nota-overlay.active .nota-sheet { transform: translateY(0); }
.drag-handle { width: 45px; height: 5px; background: #cbd5e1; border-radius: 5px; margin: 0 auto 25px auto; }
.modal-body { overflow-y: auto; flex: 1; padding-bottom: 10px; margin-bottom: 10px;}
.btn-close-modal { width: 100%; padding: 15px; background: #f1f5f9; color: #475569; border: none; border-radius: 14px; font-weight: 600; cursor: pointer; font-size:15px; transition:0.2s;}
.btn-close-modal:active { background: #e2e8f0; }

.preview-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 200; display: none; flex-direction: column; justify-content: center; align-items: center;}
.preview-content { max-width: 100%; max-height: 80vh; object-fit: contain; pointer-events: auto;}
.preview-controls { position: absolute; top: 25px; right: 25px; display: flex; gap: 15px; z-index: 210;}
.btn-preview-opt { background: rgba(255,255,255,0.2); color: white; border: none; width: 45px; height: 45px; border-radius: 50%; font-size: 20px; cursor: pointer; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(10px); transition: 0.2s;}
.btn-preview-opt:active { background: rgba(255,255,255,0.4); transform: scale(0.9);}

.cropper-container-wrapper { width: 100%; height: 300px; background: #f1f5f9; border-radius: 16px; overflow: hidden; margin-bottom: 20px; border: 1px solid #e2e8f0;}
.upload-preview-item { position: relative; width: 80px; height: 80px; border-radius: 12px; overflow: hidden; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 2px solid white;}
.upload-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.btn-del-preview { position: absolute; top: 4px; right: 4px; background: rgba(220, 38, 38, 0.9); color: white; border: none; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; cursor: pointer; display: flex; justify-content: center; align-items: center; z-index: 5; backdrop-filter:blur(2px);}

/* CUSTOM ANDROID ALERTS, TOASTS & HEADS-UP */
.android-dialog-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 9999; display: none; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.2s; }
.android-dialog-overlay.active { display: flex; opacity: 1; }
.android-dialog { background: white; width: 85%; max-width: 320px; border-radius: 28px; padding: 24px; box-shadow: 0 4px 24px rgba(0,0,0,0.2); transform: scale(0.9); transition: transform 0.2s; }
.android-dialog-overlay.active .android-dialog { transform: scale(1); }
.android-dialog-title { font-size: 20px; font-weight: 600; color: #1e293b; margin-bottom: 12px; }
.android-dialog-text { font-size: 14px; color: #475569; line-height: 1.5; margin-bottom: 24px; }
.android-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.android-btn { background: transparent; border: none; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 8px; transition: 0.2s;}
.android-btn-cancel { color: #64748b; }
.android-btn-confirm { color: #dc2626; }
.android-btn:active { background: #f1f5f9; }

/* Spinner Style */
.android-loading { display: flex; align-items: center; gap: 15px; margin-bottom: 20px;}
.spinner { width: 24px; height: 24px; border: 3px solid #f1f5f9; border-top: 3px solid #dc2626; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Toast (Bottom Pill) */
#toast-container { position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%); z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; align-items: center;}
.android-toast { background: #334155; color: white; padding: 12px 24px; border-radius: 100px; font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: toastFadeIn 0.3s, toastFadeOut 0.3s 2.5s forwards; }
@keyframes toastFadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Heads-Up Notification (Top Notification) */
#heads-up-container { position: fixed; top: 20px; left: 10px; right: 10px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.heads-up-notif { background: white; padding: 14px 16px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); display: flex; align-items: center; gap: 12px; animation: headsUpEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), headsUpLeave 0.3s 3s forwards; border-left: 4px solid #dc2626; pointer-events: auto;}
.heads-up-icon { background: #fee2e2; color: #dc2626; width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 16px; flex-shrink: 0;}
.heads-up-body { flex: 1; overflow: hidden;}
.heads-up-title { font-size: 14px; font-weight: 600; color: #1e293b; margin-bottom: 2px;}
.heads-up-text { font-size: 13px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;}
@keyframes headsUpEnter { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes headsUpLeave { from { opacity: 1; } to { opacity: 0; transform: translateY(-20px); } }

::-webkit-scrollbar { width: 5px; } ::-webkit-scrollbar-track { background: transparent; } ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }