/* ================= 1. BASE & GLOBALS ================= */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: sans-serif; }
body { background-color: #f0f2f5; padding-bottom: 80px; }

/* ================= 2. ULTIMATE SOFT-UI HEADER ================= */
.app-header { 
    background: #f0f2f5; 
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.soft-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 18px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 14px;
    border: 1px solid rgba(0,0,0,0.02);
}

.action-bar { display: flex; justify-content: space-between; align-items: center; }
.app-tag { font-size: 0.7rem; font-weight: 900; color: #1a1a1a; letter-spacing: 1.5px; opacity: 0.6; }

.soft-reset-btn {
    background: #fff5f5;
    border: none;
    color: #e53e3e;
    padding: 6px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}
.soft-reset-btn:active { transform: scale(0.92); background: #fed7d7; }

.soft-input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.95rem;
    color: #1e293b;
    outline: none;
    transition: all 0.2s ease;
}
.soft-input:focus { background: #ffffff; border-color: #3182ce; box-shadow: 0 0 0 4px rgba(49, 130, 206, 0.1); }

.school-hero {
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    border: none;
    background: transparent;
    border-bottom: 2px solid #edf2f7;
    border-radius: 0;
    padding: 5px 0;
}

.soft-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-field label, .date-wrapper label {
    display: block; font-size: 0.6rem; font-weight: 800; color: #94a3b8; 
    margin-bottom: 5px; margin-left: 4px; letter-spacing: 0.5px;
}

.soft-footer { display: flex; justify-content: space-between; align-items: flex-end; }
.date-picker { max-width: 150px; }

.score-pill {
    background: #1a1a1a; color: white; padding: 10px 20px;
    border-radius: 16px; box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}
.score-text { display: flex; flex-direction: column; align-items: center; }
#mobile-total-marks { font-size: 1.4rem; font-weight: 900; line-height: 1; }
.score-text small { font-size: 0.55rem; font-weight: 700; opacity: 0.7; margin-top: 2px; }

/* ================= 3. MOBILE UI (Questions & Actions) ================= */
.question-list { padding: 15px; }

/* Edit & Delete Buttons */
.q-actions { display: flex; gap: 10px; }
.btn-edit {
    background: #eef2ff; color: #6366f1; border: 1px solid #c7d2fe;
    padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: bold; cursor: pointer;
}
.btn-delete {
    background: #fff5f5; color: #e53e3e; border: 1px solid #fed7d7;
    padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: bold; cursor: pointer;
}
.btn-edit:active, .btn-delete:active { transform: scale(0.9); }

/* Bottom Action Bar */
.bottom-bar { position: fixed; bottom: 0; width: 100%; background: white; padding: 15px; box-shadow: 0 -2px 5px rgba(0,0,0,0.05); z-index: 99; }
.bottom-bar button { width: 100%; padding: 12px; background: #008069; color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer;}
.fab-btn { position: fixed; bottom: 85px; right: 20px; background: #25D366; color: white; width: 60px; height: 60px; border-radius: 50%; font-size: 30px; border: none; box-shadow: 0 4px 10px rgba(0,0,0,0.3); z-index: 1000; cursor: pointer; }

/* ================= 4. APP FOOTER SIGNATURE ================= */
.app-footer { padding: 30px 20px 100px 20px; text-align: center; background: transparent; }
.footer-content { display: flex; flex-direction: column; gap: 5px; align-items: center; }
.made-by { font-size: 0.85rem; color: #64748b; font-weight: 600; display: flex; align-items: center; gap: 5px; }
.heart-icon { color: #e53e3e; display: inline-block; animation: heartBeat 1.5s infinite; }
.author-name { color: #1a1a1a; font-weight: 800; letter-spacing: 0.5px; }
.app-version { font-size: 0.65rem; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; }

@keyframes heartBeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.2); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
    60% { transform: scale(1); }
}

/* ================= 5. MODAL (Popups) ================= */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; z-index: 2000; }
.modal.hidden { display: none; }
.modal-content { background: white; width: 100%; padding: 20px; border-radius: 20px 20px 0 0; }
.modal-content textarea { width: 100%; margin: 15px 0; padding: 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-save { background: #008069; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; }
.btn-cancel { background: #ccc; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer; }

/* Quick Marks Buttons */
.q-mark-btn {
    flex: 1; padding: 10px 0; background: #e0f2f1; border: 1px solid #008069; color: #008069;
    border-radius: 6px; font-weight: bold; font-size: 1rem; cursor: pointer; transition: all 0.2s;
}
.q-mark-btn:active { background: #008069; color: white; transform: scale(0.95); }
.m-input { flex: 1; padding: 8px; border-radius: 5px; border: 1px solid #ccc; }
/* ================= 6. NATIVE BROWSER PRINT ENGINE ================= */
#print-view-container { display: none; } /* Normal view me hide rahega */

@media print {
    /* Print karte waqt App UI hide kar do */
    #app-view, .modal, .bottom-bar, .fab-btn {
        display: none !important;
    }

    /* Sirf Paper show karo */
    #print-view-container {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        background: white;
    }

    /* Body background reset */
    body { background: white; margin: 0; padding: 0; }

    /* Page Setup */
    @page { 
        size: A4 portrait; 
        margin: 15mm; 
    }

    /* Paper Styling */
    .a4-paper {
        font-family: 'Times New Roman', Times, serif;
        font-size: 16px;
        line-height: 1.5;
        color: black;
        width: 100%;
    }

    /* Bulletproof Page Breaks */
    .q-wrapper, .section-title, .section-instruction {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin-bottom: 15px;
    }
    
    img {
        max-height: 200px;
        max-width: 100%;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin: 10px auto;
        display: block;
    }

    /* Layouts */
    .header-table { width: 100%; border-bottom: 2px solid black; margin-bottom: 20px; padding-bottom: 10px; }
    .school-name { text-align: center; font-size: 24px; font-weight: bold; margin-bottom: 10px; text-transform: uppercase; }
    .center-align { text-align: center; font-weight: bold; font-size: 18px; }
    .right-align { text-align: right; }
    
    .question-row { display: flex; margin-bottom: 10px; }
    .q-no { width: 40px; font-weight: bold; flex-shrink: 0; }
    .q-text { flex: 1; text-align: justify; padding-right: 15px; }
    .q-marks { width: 40px; font-weight: bold; text-align: right; flex-shrink: 0; }
    
    .sub-question-row { display: flex; margin-bottom: 8px; margin-left: 30px; }
    .sub-q-no { width: 35px; font-weight: bold; flex-shrink: 0; }
    
    .section-title { text-align: center; font-weight: bold; font-size: 18px; margin-top: 20px; }
    .section-instruction { display: flex; justify-content: space-between; font-weight: bold; margin-bottom: 15px; }
    .or-divider { text-align: center; font-weight: bold; font-style: italic; margin: 10px 0; }
    
    .mcq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 20px; margin-top: 5px; }
    .match-table { width: 80%; margin: 10px 0; border-collapse: collapse; }
    .match-table td { padding: 5px; vertical-align: top; }
    .footer { text-align: center; font-weight: bold; margin-top: 30px; border-top: 1px dashed black; padding-top: 10px; }
}

.loader {
  width: fit-content;
  height: fit-content;
  display: flex;
  align-items: center;
  justify-content: center;
}

.truckWrapper {
  width: 200px;
  height: 100px;
  display: flex;
  flex-direction: column;
  position: relative;
  align-items: center;
  justify-content: flex-end;
  overflow-x: hidden;
}
/* truck upper body */
.truckBody {
  width: 130px;
  height: fit-content;
  margin-bottom: 6px;
  animation: motion 1s linear infinite;
}
/* truck suspension animation*/
@keyframes motion {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(3px);
  }
  100% {
    transform: translateY(0px);
  }
}
/* truck's tires */
.truckTires {
  width: 130px;
  height: fit-content;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0px 10px 0px 15px;
  position: absolute;
  bottom: 0;
}
.truckTires svg {
  width: 24px;
}

.road {
  width: 100%;
  height: 1.5px;
  background-color: #282828;
  position: relative;
  bottom: 0;
  align-self: flex-end;
  border-radius: 3px;
}
.road::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 100%;
  background-color: #282828;
  right: -50%;
  border-radius: 3px;
  animation: roadAnimation 1.4s linear infinite;
  border-left: 10px solid white;
}
.road::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 100%;
  background-color: #282828;
  right: -65%;
  border-radius: 3px;
  animation: roadAnimation 1.4s linear infinite;
  border-left: 4px solid white;
}

.lampPost {
  position: absolute;
  bottom: 0;
  right: -90%;
  height: 90px;
  animation: roadAnimation 1.4s linear infinite;
}

@keyframes roadAnimation {
  0% {
    transform: translateX(0px);
  }
  100% {
    transform: translateX(-350px);
  }
}


/* Ai bot code */
/* Floating Action Button */
.ai-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: #0f9d58; /* Matching your "Generate PDF" button color */
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(15, 157, 88, 0.4);
  cursor: pointer;
  z-index: 999;
  transition: transform 0.2s ease;
}

.ai-fab:hover {
  transform: translateY(-3px);
}

/* Background Overlay */
.ai-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: none; /* Hidden by default */
}

/* Side Drawer */
.ai-drawer {
  position: fixed;
  top: 0;
  right: -450px; /* Hidden off-screen */
  width: 400px;
  height: 100vh;
  background: #ffffff;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  transition: right 0.3s ease-in-out;
  display: flex;
  flex-direction: column;
}

.ai-drawer.open {
  right: 0; /* Slide in */
}

.ai-drawer-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #555;
}

.ai-drawer-content {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

/* Tabs */
.ai-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
}

.ai-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #777;
}

.ai-tab.active {
  color: #0f9d58;
  border-bottom: 2px solid #0f9d58;
}

/* Inputs & Forms */
.ai-tab-content label {
  display: block;
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
}

.ai-tab-content textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 20px;
}

.ai-file-dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  color: #666;
  background: #f9f9f9;
  margin-bottom: 15px;
  cursor: pointer;
}

.ai-file-dropzone input {
  width: 100%;
}

/* Buttons */
.ai-primary-btn, .ai-success-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  color: white;
  cursor: pointer;
  margin-top: 10px;
}

.ai-primary-btn { background-color: #333; }
.ai-primary-btn:hover { background-color: #111; }

.ai-success-btn { background-color: #0f9d58; }
.ai-success-btn:hover { background-color: #0c8248; }

/* Result Box */
.ai-result-area {
  margin-top: 30px;
  border-top: 1px solid #e0e0e0;
  padding-top: 20px;
}

.ai-output-box {
  background: #f1f3f4;
  padding: 15px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 15px;
}

/* Hide AI Assistant elements during Print or PDF Generation */
@media print {
  .ai-fab,
  .ai-drawer,
  .ai-overlay {
    display: none !important;
  }
}

/* AI Question Cards inside the existing preview box */
.ai-question-card {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ai-question-text {
  font-size: 14px;
  color: #333;
  margin: 0;
  flex-grow: 1;
  white-space: pre-wrap;
}

.ai-copy-btn {
  background: #e3f2fd;
  color: #1976d2;
  border: none;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  flex-shrink: 0;
}

.ai-copy-btn:hover { background: #bbdefb; }
.ai-copy-btn.copied { background: #e8f5e9; color: #2e7d32; }

/* Ensure three tabs wrap nicely if required or stay inline */
.ai-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
  gap: 5px;
}

.ai-tab {
  flex: 1;
  padding: 10px 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #777;
  font-size: 13px; /* Slightly reduced for 3 tabs layout */
  text-align: center;
}

.ai-tab-content {
  display: none;
}
.ai-tab-content.active {
  display: block;
}
/* Ensure three tabs wrap nicely if required or stay inline */
.ai-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
  gap: 5px;
}

.ai-tab {
  flex: 1;
  padding: 10px 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: bold;
  color: #777;
  font-size: 13px; /* Slightly reduced for 3 tabs layout */
  text-align: center;
}

.ai-tab-content {
  display: none;
}
.ai-tab-content.active {
  display: block;
}

/* ================= PASSWORD LOCK SCREEN ================= */
.pass-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Dark transparent background */
    backdrop-filter: blur(8px); /* Blurs the app behind it */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999; /* Sabse upar rakhne ke liye */
}

.pass-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    width: 90%;
    max-width: 400px;
}

.pass-card h2 {
    margin-bottom: 10px;
    color: #333;
}

.pass-card p {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
}

.pass-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}

.pass-card input:focus {
    border-color: #008069;
}

.pass-card button {
    width: 100%;
    padding: 12px;
    background: #008069;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.pass-card button:hover {
    background: #006955;
}

.pass-error {
    color: red;
    font-size: 13px;
    font-weight: bold;
    margin-top: 15px;
    display: none; /* By default hidden */
}

/* ================= AI INSTRUCTIONS TEXTAREA ================= */
#ai-sol-context {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    margin-top: 15px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: #333;
    resize: vertical; /* Isse user sirf upar-neeche bada kar payega, layout nahi tootega */
    outline: none;
    transition: all 0.2s ease-in-out;
}

#ai-sol-context:focus {
    border-color: #e65100; /* Focus karne par theme wala orange color aayega */
    box-shadow: 0 0 5px rgba(230, 81, 0, 0.2);
}