@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg: #F4F7FB;
  --card-bg: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  --danger: #EF4444;
  --success: #10B981;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Typography */
h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; cursor: pointer; }
a:hover { color: var(--primary-hover); }

/* Layout */
.container { max-width: 800px; margin: 0 auto; padding: 0 20px; }
.header {
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
  padding: 15px 0;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; font-weight: 500; font-size: 0.9rem;
  border-radius: 8px; border: none; cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 6px rgba(79, 70, 229, 0.2); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 10px rgba(79, 70, 229, 0.3); }
.btn-outline { background: transparent; color: var(--text-main); border: 1px solid var(--border); }
.btn-outline:hover { background: #F8FAFC; }
.btn-danger { background: #FEF2F2; color: var(--danger); }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; border-radius: 6px; }

/* Cards & Posts */
.post-section { margin-top: 30px; padding-bottom: 50px; }
.post-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm); border: 1px solid transparent;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.post-card:hover { box-shadow: var(--shadow-md); border-color: rgba(79, 70, 229, 0.1); }
.post-header { display: flex; justify-content: space-between; margin-bottom: 12px; align-items: center; }
.post-author { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.post-author .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: bold; }
.post-date { color: var(--text-muted); font-size: 0.8rem; }
.post-content { font-size: 1.05rem; white-space: pre-wrap; margin-bottom: 16px; }
.post-actions { display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--border); padding-top: 12px; }
.action-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 0.85rem; font-weight: 500; transition: color 0.2s; }
.action-btn:hover { color: var(--primary); }
.action-btn.active-like { color: var(--success); }
.action-btn.active-dislike { color: var(--danger); }
.action-btn.btn-answer-highlight {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
}
.action-btn.btn-answer-highlight:hover { background: rgba(79, 70, 229, 0.15); transform: translateY(-1px); }
.action-btn i { font-size: 1.1rem; }

/* Answers & Replies */
.answers-container { margin-top: 20px; border-left: 2px solid var(--border); padding-left: 20px; }
.answer-card {
  background: #FAFAFA; border-radius: 8px; padding: 16px; margin-bottom: 12px;
  border: 1px solid #F1F5F9;
}
.replies-container { margin-top: 12px; border-left: 2px solid #E2E8F0; padding-left: 16px; margin-left: 8px; }
.reply-card { background: #FFFFFF; padding: 12px; border-radius: 8px; margin-bottom: 8px; border: 1px solid #F1F5F9; }

/* Modals */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--card-bg); border-radius: var(--radius);
  width: 90%; max-width: 450px; padding: 24px;
  box-shadow: var(--shadow-lg); transform: translateY(20px); transition: transform 0.3s;
  max-height: 70vh; overflow-y: auto; display: flex; flex-direction: column;
}
.modal-backdrop.active .modal { transform: translateY(0); }
.modal-header { font-size: 1.25rem; font-weight: 600; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.95rem; transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* Utilities */
.hidden { display: none !important; }
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.answer-content-wrap { cursor: pointer; transition: all 0.2s; }
.answer-content-wrap:hover { color: var(--primary); }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Toast Notification */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1E293B; color: white; padding: 12px 20px; border-radius: 8px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.show { transform: translateX(0); }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }

/* Day Divider */
.day-divider {
  display: flex; align-items: center; margin: 40px 0 20px; color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
}
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.day-divider span { padding: 0 15px; }

/* Admin Dashboard Specifics */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .admin-grid { grid-template-columns: 1fr; } }
.admin-card { background: white; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-pending { background: #FEF3C7; color: #D97706; }
.badge-resolved { background: #D1FAE5; color: #059669; }
.badge-active { background: #E0E7FF; color: #4338CA; }
.badge-blocked { background: #FEE2E2; color: #DC2626; }

/* Mobile Optimizations */
@media (max-width: 600px) {
  .header { padding: 12px 0; }
  .header-inner { flex-direction: column; gap: 12px; }
  .header-actions { width: 100%; justify-content: center; flex-wrap: wrap; gap: 10px; }
  
  #auth-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  #auth-btns span { display: none; } /* Hide greeting text */
  #auth-btns .btn, #installBtn, #shareBtn { margin: 0 !important; }
  
  .post-card { padding: 16px; margin-bottom: 12px; }
  .post-actions { flex-wrap: wrap; gap: 8px; justify-content: flex-start; }
  .action-btn { font-size: 0.8rem; padding: 4px 6px; }
  .answers-container { padding-left: 10px; margin-top: 15px; }
  .answer-card { padding: 12px; }
  .btn { padding: 8px 12px; }
  
  .modal { width: 95%; padding: 20px; max-height: 65vh; }
}

/* Anti-copy functionality */
.no-copy {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.no-copy input, .no-copy textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* Floating Action Button (Ask a Doubt) - Middle Right */
.fab-ask-btn {
    position: fixed;
    top: 40%;
    right: 0;
    transform: translateY(-50%);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50px 0 0 50px;
    padding: 14px 20px 14px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    box-shadow: -4px 4px 15px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 90;
    animation: fab-pulse 2s infinite;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.fab-ask-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-50%) scale(1.03);
    box-shadow: -6px 8px 25px rgba(79, 70, 229, 0.5);
    animation: none;
}

@keyframes fab-pulse {
    0% {
        box-shadow: -4px 4px 15px rgba(79, 70, 229, 0.4), 0 0 0 0 rgba(79, 70, 229, 0.7);
    }
    70% {
        box-shadow: -4px 4px 15px rgba(79, 70, 229, 0.4), 0 0 0 15px rgba(79, 70, 229, 0);
    }
    100% {
        box-shadow: -4px 4px 15px rgba(79, 70, 229, 0.4), 0 0 0 0 rgba(79, 70, 229, 0);
    }
}

@media (max-width: 600px) {
    .fab-ask-btn {
        top: 50%;
        padding: 12px 14px 12px 18px;
        font-size: 0.95rem;
    }
    .fab-install-btn {
        top: 62%;
        padding: 12px 14px 12px 18px;
        font-size: 0.95rem;
    }
}

/* Floating Action Button (Install App) - Middle Right below Ask Doubt */
.fab-install-btn {
    position: fixed;
    top: 52%;
    right: 0;
    transform: translateY(-50%);
    background: var(--success);
    color: white;
    border: none;
    border-radius: 50px 0 0 50px;
    padding: 14px 20px 14px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    box-shadow: -4px 4px 15px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 90;
    animation: fab-install-pulse 2s infinite;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.fab-install-btn:hover {
    background: #059669; /* darker success */
    transform: translateY(-50%) scale(1.03);
    box-shadow: -6px 8px 25px rgba(16, 185, 129, 0.5);
    animation: none;
}

@keyframes fab-install-pulse {
    0% {
        box-shadow: -4px 4px 15px rgba(16, 185, 129, 0.4), 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: -4px 4px 15px rgba(16, 185, 129, 0.4), 0 0 0 15px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: -4px 4px 15px rgba(16, 185, 129, 0.4), 0 0 0 0 rgba(16, 185, 129, 0);
    }
}
