/* ========================================================= */
/* style.css - Noon Mart (Ultra Premium + WhatsApp Style Chat)*/
/* ========================================================= */

:root {
    --bg-gradient: linear-gradient(135deg, #02000a 0%, #0a1428 50%, #000000 100%);
    --text-primary: #ffffff;
    --text-secondary: #a1a1a6;
    --apple-blue: #007aff;
    --apple-blue-hover: #0062cc;
    --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-highlight: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --danger: #ff3b30;
    --success: #34c759;
    --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-stack); -webkit-font-smoothing: antialiased; }
a, a:hover, a:visited, a:active, .logo { text-decoration: none !important; color: inherit; border-bottom: none !important; outline: none !important; }

body { background: var(--bg-gradient); background-attachment: fixed; color: var(--text-primary); min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; width: 100vw; }

h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.04em; color: var(--text-primary); line-height: 1.2; }
p { line-height: 1.6; color: var(--text-secondary); font-size: 1.05rem; }

.shimmer-text { background: linear-gradient(90deg, #fff 0%, var(--apple-blue) 50%, #fff 100%); background-size: 200% auto; color: transparent; -webkit-background-clip: text; background-clip: text; animation: shimmer 4s linear infinite; }
@keyframes shimmer { to { background-position: 200% center; } }

.page-loader { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #000; z-index: 10000; display: flex; justify-content: center; align-items: center; transition: opacity 0.5s; }
.page-loader.hidden { opacity: 0; visibility: hidden; pointer-events: none;}
.loader-spinner { width: 50px; height: 50px; border: 3px solid rgba(255,255,255,0.1); border-top: 3px solid var(--apple-blue); border-radius: 50%; animation: spin 1s infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; flex: 1; }
.navbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; background: rgba(5, 10, 20, 0.8); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--glass-border); height: 70px; display: flex; align-items: center;}
.nav-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.8rem; font-weight: 800; letter-spacing: -1px; margin: 0 !important; padding: 0 !important;}
.logo span { color: var(--apple-blue); }
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links a { font-size: 1rem; font-weight: 600; transition: var(--transition); }
.user-menu { display: flex; gap: 15px; align-items: center; border-left: 1px solid var(--glass-border); padding-left: 15px; }
.mobile-menu-btn { display: none; background: transparent; border: none; color: white; font-size: 2rem; cursor: pointer; outline: none; padding: 5px;}

.mobile-drawer { position: fixed; top: 0; right: -100%; width: 85vw; max-width: 350px; height: 100vh; background: rgba(5, 10, 20, 0.98); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px); z-index: 1000; padding: 30px; transition: right 0.4s ease; border-left: 1px solid var(--glass-highlight); box-shadow: -10px 0 50px rgba(0,0,0,0.8);}
.mobile-drawer.open { right: 0; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--glass-border); padding-bottom: 20px; }
.drawer-header button { background: none; border: none; color: white; font-size: 2rem; cursor: pointer;}
.drawer-profile { display: flex; align-items: center; gap: 15px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--glass-border); }
.drawer-profile h4 { font-size: 1.2rem; margin-bottom: 4px; }
.drawer-links { display: flex; flex-direction: column; gap: 25px; }
.drawer-links a { font-size: 1.2rem; font-weight: 600; display: flex; align-items: center; gap: 15px; color: white !important;}

button, .primary-btn, .secondary-btn { font-family: var(--font-stack); border-radius: 980px; font-weight: 700; font-size: 1rem; padding: 14px 24px; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; cursor: pointer; text-decoration: none !important; outline: none;}
.primary-btn { background: var(--apple-blue) !important; color: white !important; }
.secondary-btn { background: rgba(255,255,255,0.1) !important; color: white !important; border: 1px solid var(--glass-border) !important; }
.icon-btn { border-radius: 50%; width: 50px; height: 50px; padding: 0; display: flex; align-items: center; justify-content: center; flex-shrink: 0;}
.icon-btn.danger { background: rgba(255,59,48,0.15) !important; color: var(--danger) !important; }
.full-width { width: 100%; }

.google-btn { background: #ffffff !important; color: #333333 !important; border-radius: 980px !important; display: flex !important; align-items: center !important; justify-content: center !important; gap: 12px !important; margin-top: 15px !important; height: 50px !important; padding: 0 20px !important; font-size: 1rem !important; box-shadow: 0 4px 15px rgba(255,255,255,0.1) !important;}
.google-btn img { width: 24px !important; height: 24px !important; margin: 0 !important; padding: 0 !important; display: block !important; object-fit: contain !important;}

.divider { display: flex; align-items: center; text-align: center; margin: 25px 0; color: var(--text-secondary); font-size: 0.9rem; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--glass-border); }
.divider:not(:empty)::before { margin-right: 15px; }
.divider:not(:empty)::after { margin-left: 15px; }

.auth-tabs { display: flex; background: rgba(255,255,255,0.1); border-radius: 980px; padding: 5px; margin-bottom: 30px; }
.auth-tab { flex: 1; background: transparent !important; color: var(--text-secondary); padding: 12px; border-radius: 980px; text-align: center; font-weight: bold;}
.auth-tab.active { background: var(--apple-blue) !important; color: white !important; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }

.hero { margin-top: 100px; text-align: center; padding: 40px 0; }
.hero h1 { font-size: 3rem; margin-bottom: 15px; }
.hero p { font-size: 1.1rem; margin-bottom: 30px; }
.search-bar { width: 100%; max-width: 650px; margin: 0 auto; display: flex; align-items: center; background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 980px; padding: 8px; }
.search-bar input { flex: 1; background: transparent; border: none; color: white; padding: 0 20px; font-size: 1.1rem; outline: none; width: 100%; }

.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding-bottom: 80px; width: 100%;}
.ad-card { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 20px; overflow: hidden; width: 100%; cursor: pointer;}
.card-img-container { width: 100%; height: 200px; background: #000; }
.card-img-container img { width: 100%; height: 100%; object-fit: cover; }
.ad-card-content { padding: 20px; }
.ad-category { font-size: 0.8rem; text-transform: uppercase; color: var(--apple-blue); margin-bottom: 5px; font-weight: 700; }
.ad-card-content h3 { font-size: 1.2rem; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-price { font-size: 1.4rem; font-weight: 800; color: white; margin-bottom: 10px; }
.ad-meta { display: flex; justify-content: space-between; font-size: 0.9rem; color: var(--text-secondary);}

.skeleton-img { background: rgba(255,255,255,0.1); height: 200px; width: 100%; }
.skeleton-text { background: rgba(255,255,255,0.1); height: 18px; margin-bottom: 12px; border-radius: 6px; }

.modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 15px;}
.modal.show { display: flex; }
.modal-content { background: #0f121a; border: 1px solid rgba(255,255,255,0.15); border-radius: 24px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; padding: 25px; box-shadow: 0 30px 60px rgba(0,0,0,0.9); }
.modal-content.large-modal { max-width: 800px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.close-modal { background: rgba(255,255,255,0.1); border: 1px solid var(--glass-border); color: white; width: 40px; height: 40px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer;}

.form-group { margin-bottom: 20px; width: 100%;}
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; color: var(--text-secondary);}
.form-group input, .form-group select, .form-group textarea { width: 100%; background: rgba(0,0,0,0.5); border: 1px solid var(--glass-border); border-radius: 12px; padding: 14px; color: white; font-size: 1rem; outline: none; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--apple-blue); }

.ad-detail-body { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.main-image-container { border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 4/3; }
.main-image-container img { width: 100%; height: 100%; object-fit: contain; }
.thumbnails { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0; }
.thumbnails img { width: 70px; height: 70px; object-fit: cover; border-radius: 10px; opacity: 0.5; border: 2px solid transparent;}
.thumbnails img.active { opacity: 1; border-color: var(--apple-blue); }
.price-tag { font-size: 2rem; font-weight: 800; color: white; margin-bottom: 15px;}
.meta-info { display: flex; flex-wrap: wrap; margin-bottom: 20px;}
.meta-info span { display: flex; align-items: center; font-weight: 600; margin-right: 20px; margin-bottom: 10px; font-size: 1rem;}
.meta-info span i { margin-right: 6px; font-size: 1.2rem; color: var(--apple-blue); }
.seller-card { background: rgba(255,255,255,0.05); border-radius: 16px; padding: 15px; margin: 20px 0;}
.seller-info { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.avatar { width: 50px; height: 50px; background: rgba(255,255,255,0.1); border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.5rem; }
.hidden-contact { filter: blur(5px); }
.seller-actions { display: flex; gap: 10px; }
.seller-actions button { flex: 1; }

.admin-layout { display: flex; width: 100%; min-height: 100vh; }
.admin-sidebar { width: 280px; background: rgba(10,15,25,0.9); border-right: 1px solid var(--glass-border); padding: 30px 20px; display: flex; flex-direction: column; gap: 15px; }
.admin-stats { display: flex; gap: 15px; }
.stat-box { background: rgba(0,0,0,0.5); border: 1px solid var(--glass-border); padding: 15px; border-radius: 16px; flex: 1; text-align: center;}
.admin-nav-links { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.admin-tab { background: rgba(255,255,255,0.05) !important; border: 1px solid var(--glass-border) !important; color: white !important; padding: 15px; border-radius: 12px; text-align: left; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; width: 100%; font-size: 1.1rem;}
.admin-tab.active { background: var(--apple-blue) !important; border-color: var(--apple-blue) !important; }
.admin-content { flex: 1; padding: 30px; overflow-y: auto;}
.admin-cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.admin-card { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 15px;}
.admin-card-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--glass-border); padding-bottom: 10px;}
.admin-card-actions { display: flex; gap: 10px; margin-top: auto; }

.auth-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; flex-direction: column; padding: 20px;}
.auth-container { width: 100%; max-width: 450px; }
.glass-panel { background: rgba(10,15,25,0.85); backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: 24px; padding: 30px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); width: 100%;}
.hidden { display: none !important; }
.main-footer { text-align: center; padding: 30px; border-top: 1px solid var(--glass-border); margin-top: auto; width: 100%;}

/* ========================================================= */
/* --- PERFECT MOBILE & WHATSAPP CHAT FIXES --- */
/* ========================================================= */

.messages-layout .messages-container { display: flex; height: 65vh; min-height: 500px; border: 1px solid var(--glass-border); border-radius: 24px; overflow: hidden; background: #0b0c10; width: 100%;}
.inbox-list { width: 35%; border-right: 1px solid var(--glass-border); overflow-y: auto; background: rgba(255,255,255,0.02);}
.inbox-item { padding: 15px 20px; border-bottom: 1px solid var(--glass-border); transition: var(--transition); display: flex; align-items: center; gap: 15px; cursor: pointer;}
.inbox-item:hover, .inbox-item.active-chat { background: rgba(255,255,255,0.05); border-left: 3px solid var(--apple-blue); }
.inbox-item .text-content { overflow: hidden; flex: 1; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-window { width: 65%; display: flex; flex-direction: column; position: relative; background: #12141a; }
.chat-header { padding: 15px 20px; background: rgba(20,22,30,0.9); border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; gap: 10px;}
.chat-history { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; } /* Changed to Flex Column */

/* --- THE FIX: WhatsApp Style Bubbles --- */
.chat-bubble { 
    max-width: 75%; 
    padding: 10px 16px; 
    border-radius: 18px; 
    font-size: 1.05rem; 
    line-height: 1.4; 
    word-wrap: break-word;
    width: fit-content; /* This makes it bubble-shaped instead of full width */
    display: block;
}
.chat-bubble.in { 
    background: #2a2d36; /* Dark grey for incoming */
    border-bottom-left-radius: 4px; 
    align-self: flex-start; /* Pushes to left */
    color: white;
}
.chat-bubble.out { 
    background: var(--apple-blue); /* Blue for outgoing */
    border-bottom-right-radius: 4px; 
    align-self: flex-end; /* Pushes to right */
    color: white;
    box-shadow: 0 4px 15px rgba(0,122,255,0.2);
}

.chat-input-area { padding: 15px; background: rgba(20,22,30,0.9); border-top: 1px solid var(--glass-border); display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box;}
.chat-input-area input { flex: 1 1 auto; width: 100%; height: 50px; background: rgba(255,255,255,0.08); border-radius: 980px; padding: 0 20px; border: 1px solid transparent; color: white; outline: none; font-size: 1rem;}
.chat-input-area input:focus { border-color: var(--apple-blue); }
.chat-input-area .icon-btn { flex: 0 0 50px; width: 50px; height: 50px; border-radius: 50%; padding: 0; margin: 0;}

@media (max-width: 768px) {
    .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .nav-links { display: none; }
    .mobile-menu-btn { display: block; }
    .navbar { height: 70px; }
    .search-bar { flex-direction: column; background: transparent; border: none; padding: 0; gap: 10px;}
    .search-bar input { background: rgba(255,255,255,0.1); border: 1px solid var(--glass-border); padding: 15px; border-radius: 16px; height: 55px;}
    .search-bar button { height: 55px; border-radius: 16px; }
    .ad-detail-body { grid-template-columns: 1fr; gap: 20px; }
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--glass-border); padding: 20px; }
    .admin-content { padding: 15px; }
    .admin-cards-grid { grid-template-columns: 1fr; }
    .list-item { flex-direction: column; align-items: flex-start; gap: 15px;}
    .item-actions { width: 100%; display: flex; }
    .item-actions button { flex: 1; }

    /* Mobile Chat Fixes */
    .messages-layout .messages-container { flex-direction: column; height: 85vh; width: 100%; border-radius: 16px;}
    .inbox-list { width: 100%; border-right: none; height: 100%; overflow-y: auto; }
    .inbox-list.hidden { display: none !important; }
    .chat-window { width: 100%; height: 100%; display: flex; flex-direction: column; position: relative;}
    .chat-window.hidden { display: none !important; }
    .chat-header { padding: 15px; }
    .mobile-only { display: flex !important; background: transparent; border: none; color: white; padding: 5px; margin-right: 10px; font-size: 1.5rem;}
    .chat-input-area { padding: 10px; }
    .chat-input-area input { height: 50px; }
}