/* Define Sahel (BYekan) font-face - fonts loaded from local /fonts folder */
@font-face {
    font-family: 'BYekan';
    src: url('fonts/Sahel-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'BYekan';
    src: url('fonts/Sahel-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Custom styles */
body {
    font-family: 'BYekan', 'Tahoma', 'Arial', sans-serif;
    background: linear-gradient(to bottom right, #f3f4f6, #e5e7eb);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    margin: 0;
}

.container {
    background-color: #ffffff;
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 1.5rem;
    max-width: 60rem;
    width: 100%;
    border: 1px solid rgba(229, 231, 235, 0.6);
    margin: 1rem auto;
}

@media (min-width: 768px) {
    .container {
        padding: 2.5rem;
    }
    body {
        align-items: center;
        padding: 2rem;
    }
}

h1 {
    color: #1f2937;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

@media (min-width: 768px) {
    h1 {
        font-size: 2.5rem;
        margin-bottom: 2rem;
    }
}

h2 {
    color: #374151;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

@media (min-width: 768px) {
    h2 {
        font-size: 1.75rem;
        margin-bottom: 1.5rem;
        padding-bottom: 0.75rem;
    }
}

/* Card-like sections */
.card-section {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

@media (min-width: 768px) {
    .card-section {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
    }
    .card-section:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
    }
}

label {
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 0.4rem;
    display: block;
    font-size: 0.9rem;
}

@media (min-width: 768px) {
    label {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
}

input[type="text"],
input[type="number"],
select {
    padding: 0.65rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    background-color: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    width: 100%;
    font-family: 'BYekan', 'Tahoma', sans-serif;
    font-size: 0.9rem;
}

@media (min-width: 768px) {
    input[type="text"],
    input[type="number"],
    select {
        padding: 0.75rem;
        font-size: 1rem;
    }
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    outline: none;
}

/* Range input */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    height: 0.75rem;
    width: 100%;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: #d1d5db;
    border-radius: 0.5rem;
    height: 0.75rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-moz-range-track {
    background: #d1d5db;
    border-radius: 0.5rem;
    height: 0.75rem;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -0.625rem;
    background-color: #6366f1;
    border: 4px solid #ffffff;
    border-radius: 9999px;
    height: 2rem;
    width: 2rem;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

input[type="range"]::-moz-range-thumb {
    background-color: #6366f1;
    border: 4px solid #ffffff;
    border-radius: 9999px;
    height: 2rem;
    width: 2rem;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4);
}

input[type="range"]:focus::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.4);
}

/* Buttons */
button {
    padding: 0.75rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 0.75rem;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
    border: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-family: 'BYekan', 'Tahoma', sans-serif;
    color: white;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    button {
        padding: 0.8rem 1.8rem;
        font-size: 1.1rem;
    }
}

#addSubjectButton {
    background-image: linear-gradient(to right, #22c55e, #16a34a);
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.4);
    color: white;
}

#addSubjectButton:hover, #addSubjectButton:active {
    background-image: linear-gradient(to right, #16a34a, #15803d);
    box-shadow: 0 8px 16px rgba(34, 197, 94, 0.5);
    transform: translateY(-2px) scale(1.02);
}

/* Main action buttons - flex row on mobile */
.main-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
}

@media (min-width: 480px) {
    .main-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

#calculateButton,
#savePlanButton,
#loadPlanButton {
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 0.75rem;
    transition: all 0.3s ease-in-out;
    cursor: pointer;
    border: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    color: white;
    flex: 1;
    min-width: 0;
    font-family: 'BYekan', 'Tahoma', sans-serif;
}

@media (max-width: 479px) {
    #calculateButton,
    #savePlanButton,
    #loadPlanButton {
        width: 100%;
        flex: none;
    }
}

#calculateButton {
    background-image: linear-gradient(to right, #6366f1, #4f46e5);
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.4);
}

#calculateButton:hover, #calculateButton:active {
    background-image: linear-gradient(to right, #4f46e5, #4338ca);
    box-shadow: 0 8px 16px rgba(99, 102, 241, 0.5);
    transform: translateY(-2px) scale(1.02);
}

#savePlanButton {
    background-image: linear-gradient(to right, #22c55e, #16a34a);
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.4);
}

#savePlanButton:hover, #savePlanButton:active {
    background-image: linear-gradient(to right, #16a34a, #15803d);
    box-shadow: 0 8px 16px rgba(34, 197, 94, 0.5);
    transform: translateY(-2px) scale(1.02);
}

#loadPlanButton {
    background-image: linear-gradient(to right, #ec4899, #db2777);
    box-shadow: 0 6px 12px rgba(236, 72, 153, 0.4);
}

#loadPlanButton:hover, #loadPlanButton:active {
    background-image: linear-gradient(to right, #db2777, #be185d);
    box-shadow: 0 8px 16px rgba(236, 72, 153, 0.5);
    transform: translateY(-2px) scale(1.02);
}

#printButton {
    background-image: linear-gradient(to right, #ec4899, #db2777);
    box-shadow: 0 6px 12px rgba(236, 72, 153, 0.4);
    border-radius: 0.5rem;
    color: white;
}

#printButton:hover, #printButton:active {
    background-image: linear-gradient(to right, #db2777, #be185d);
    box-shadow: 0 8px 16px rgba(236, 72, 153, 0.5);
    transform: translateY(-2px) scale(1.02);
}

/* Subject Box Styling */
.subject-box {
    background-color: #ffffff;
    border: 1px solid #e0e7ff;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease-in-out;
    position: relative;
}

@media (min-width: 768px) {
    .subject-box {
        padding: 1.5rem;
    }
    .subject-box:hover {
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
    }
}

.subject-box h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid #c7d2fe;
    padding-bottom: 0.5rem;
    padding-left: 3rem; /* space for remove button in RTL */
}

@media (min-width: 768px) {
    .subject-box h3 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
}

.subject-box .remove-subject-button {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background-color: #ef4444;
    color: white;
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.subject-box .remove-subject-button:hover,
.subject-box .remove-subject-button:active {
    background-color: #dc2626;
    transform: scale(1.05);
}

.subject-box .resource-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-bottom: 1rem;
}

.subject-box .resource-buttons button {
    background-color: #4b5563;
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 0.6rem;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    flex: 1;
    min-width: 100px;
    text-align: center;
}

.subject-box .resource-buttons button:hover,
.subject-box .resource-buttons button:active {
    background-color: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Study Inputs within Subject Box */
.study-inputs {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px dashed #e0e7ff;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    background-color: #f0f3ff;
    padding: 1rem;
    border-radius: 0.75rem;
}

@media (min-width: 480px) {
    .study-inputs {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (min-width: 768px) {
    .study-inputs {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1.5rem;
        padding: 1.5rem;
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }
}

.study-inputs .resource-box {
    background-color: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.study-inputs .resource-box button {
    background-color: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    align-self: flex-end;
    margin-top: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.study-inputs .resource-box button:hover,
.study-inputs .resource-box button:active {
    background-color: #dc2626;
    transform: scale(1.02);
}

/* Table Styling */
#studyPlanTableContainer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#studyPlanTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1.5rem;
    border: 1px solid #e0e7ff;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    min-width: 400px; /* ensure scrollable on mobile */
}

#studyPlanTable thead {
    background-color: #e0e7ff;
}

#studyPlanTable th {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #c7d2fe;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
    color: #4338ca;
    white-space: nowrap;
}

@media (min-width: 768px) {
    #studyPlanTable th {
        padding: 1rem 1.25rem;
        font-size: 0.95rem;
    }
}

#studyPlanTable tbody tr:nth-child(even) {
    background-color: #f8faff;
}

#studyPlanTable tbody tr:hover {
    background-color: #eef2ff;
    transition: background-color 0.2s ease-in-out;
}

#studyPlanTable td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eef2ff;
    color: #374151;
    font-size: 0.85rem;
    white-space: nowrap;
}

@media (min-width: 768px) {
    #studyPlanTable td {
        padding: 1rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Grid for user info */
.grid-cols-user {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 640px) {
    .grid-cols-user {
        grid-template-columns: 1fr 1fr;
    }
}

/* Message Styling */
.message {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    margin-top: 1rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease-out;
    font-size: 0.9rem;
}

@media (min-width: 768px) {
    .message {
        padding: 1rem 1.5rem;
        margin-top: 1.5rem;
        font-size: 1rem;
    }
}

.green-message {
    background-color: #dcfce7;
    color: #14532d;
    border: 1px solid #86efad;
}

.yellow-message {
    background-color: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.red-message {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
}

/* Modal Styling */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    overflow-y: auto;
    animation: fadeIn 0.3s ease-out;
}

@media (min-width: 640px) {
    .modal {
        align-items: center;
    }
}

.modal-content {
    background-color: white;
    padding: 1.5rem;
    border-radius: 1.25rem;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    text-align: right;
    position: relative;
    animation: slideInFromTop 0.4s ease-out;
    margin: 1rem auto;
}

@media (min-width: 768px) {
    .modal-content {
        padding: 2.5rem;
        margin: auto;
    }
}

.modal-content h3 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 1.5rem;
    text-align: center;
    border-bottom: 2px solid #e0e7ff;
    padding-bottom: 0.75rem;
}

@media (min-width: 768px) {
    .modal-content h3 {
        font-size: 1.75rem;
        margin-bottom: 2rem;
        padding-bottom: 1rem;
    }
}

.modal-content label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
    display: block;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid #d1d5db;
    width: 100%;
    box-sizing: border-box;
    font-family: 'BYekan', 'Tahoma', sans-serif;
}

@media (min-width: 768px) {
    .modal-content input[type="text"],
    .modal-content input[type="number"],
    .modal-content select {
        margin-bottom: 1.5rem;
    }
}

.modal-content .modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (min-width: 480px) {
    .modal-content .modal-buttons {
        flex-direction: row;
        justify-content: flex-end;
        gap: 1rem;
        margin-top: 2rem;
    }
}

.modal-content .modal-buttons button {
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-family: 'BYekan', 'Tahoma', sans-serif;
    flex: 1;
}

@media (min-width: 480px) {
    .modal-content .modal-buttons button {
        flex: none;
        padding: 0.8rem 1.8rem;
    }
}

.modal-content .modal-buttons button.save-button {
    background-color: #22c55e;
    color: white;
}

.modal-content .modal-buttons button.save-button:hover,
.modal-content .modal-buttons button.save-button:active {
    background-color: #16a34a;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-content .modal-buttons button.close-button {
    background-color: #ef4444;
    color: white;
}

.modal-content .modal-buttons button.close-button:hover,
.modal-content .modal-buttons button.close-button:active {
    background-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInFromTop {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Deficit display */
.deficit-box {
    display: inline-block;
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #f87171;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    margin-right: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Slider labels */
.slider-labels {
    position: relative;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    font-size: 0.7rem;
    color: #16a34a;
    height: 1.8rem;
    margin-top: 0.2rem;
}

@media (max-width: 767px) {
    .slider-labels {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .slider-labels {
        font-size: 0.75rem;
    }
}

.slider-label {
    position: absolute;
    transform: translateX(50%);
    cursor: pointer;
    pointer-events: auto;
    background-color: transparent;
    padding: 0.2rem 0.3rem;
    border-radius: 0.3rem;
    border: 1px solid transparent;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.slider-label:hover {
    background-color: #dcfce7;
    color: #15803d;
    border-color: #86efad;
}

/* PDF logo */
.pdf-header-content {
    position: relative;
    width: 100%;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.pdf-logo-small {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 50px;
    height: 50px;
    object-fit: contain;
    z-index: 10;
}

/* Logo image responsive */
.logo-img {
    width: 5rem;
    height: 5rem;
    margin: 0 auto 1rem;
    display: block;
    object-fit: contain;
}

@media (min-width: 768px) {
    .logo-img {
        width: 6rem;
        height: 6rem;
        margin-bottom: 1rem;
    }
}

/* Welcome message */
#welcomeMessage {
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    color: #2563eb;
    margin-top: 1rem;
}

#userMessage {
    text-align: center;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* Range value display */
#rangeValue {
    display: block;
    text-align: center;
    color: #6366f1;
    font-weight: 600;
    margin-top: 0.5rem;
    font-size: 1rem;
}

/* subjects container spacing */
#subjectsContainer {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    #subjectsContainer {
        gap: 1.5rem;
    }
}

/* Study plan table container */
#studyPlanTableContainer {
    margin-top: 2rem;
}

#studyPlanTableContainer h2 {
    text-align: center;
    margin-bottom: 1rem;
}

/* Print button container */
.print-button-container {
    text-align: center;
    margin-top: 1.5rem;
}

/* Scrollbar for table on mobile */
.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 1rem;
}

/* Utility classes used by JS */
.hidden { display: none !important; }
.block { display: block; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.text-lg { font-size: 1.125rem; }
.text-md { font-size: 1rem; }
.text-blue-600 { color: #2563eb; }
.overflow-x-auto { overflow-x: auto; }
.space-y-4 > * + * { margin-top: 1rem; }
.flex { display: flex; }
.justify-center { justify-content: center; }
.gap-4 { gap: 1rem; }

/* Tailwind-like grid */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}
.gap-4 { gap: 1rem; }


/* Classes used dynamically by script.js */
.slider-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.range-value-span {
    display: block;
    text-align: center;
    color: #6366f1;
    font-weight: 600;
    margin-top: 0.5rem;
}

.remove-resource-button {
    background-color: #ef4444;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-family: 'BYekan', 'Tahoma', sans-serif;
    font-weight: 700;
    transition: background-color 0.2s;
    touch-action: manipulation;
}

.remove-resource-button:hover,
.remove-resource-button:active {
    background-color: #dc2626;
}

/* text-center mb-6 used in pdf header */
.text-center.mb-6 {
    text-align: center;
    margin-bottom: 1.5rem;
}


/* ============================================================
   BOTTOM NAVIGATION BAR — Floating, Responsive, Vivid
   ============================================================ */

.bottom-nav {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 480px;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4c1d95 100%);
    border-radius: 2rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom, 0));
    z-index: 200;
    box-shadow:
        0 8px 32px rgba(99, 102, 241, 0.45),
        0 2px 8px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 640px) {
    .bottom-nav {
        bottom: 1.5rem;
        max-width: 600px;
        padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0));
    }
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.45rem 0.3rem;
    border-radius: 1.25rem;
    transition: background 0.22s ease, transform 0.18s ease;
    color: rgba(199, 210, 254, 0.75);
    font-family: 'BYekan', 'Tahoma', sans-serif;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-btn:hover {
    color: #c7d2fe;
    background: rgba(255,255,255,0.08);
}

.bottom-nav-btn:active {
    transform: scale(0.93);
    background: rgba(255,255,255,0.13);
}

.bottom-nav-btn.active {
    color: #ffffff;
    background: rgba(255,255,255,0.15);
}

/* Glowing pill indicator under active icon */
.bottom-nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0.2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 1.4rem;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, #a5b4fc, #818cf8);
    box-shadow: 0 0 8px rgba(165, 180, 252, 0.8);
}

.bottom-nav-icon-wrap {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.22s, box-shadow 0.22s;
    position: relative;
}

.bottom-nav-btn.active .bottom-nav-icon-wrap {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.55);
}

.bottom-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    display: block;
}

.bottom-nav-label {
    font-size: 0.6rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.02em;
    transition: color 0.2s;
}

@media (min-width: 400px) {
    .bottom-nav-icon { font-size: 1.35rem; }
    .bottom-nav-label { font-size: 0.65rem; }
    .bottom-nav-icon-wrap { width: 2.6rem; height: 2.6rem; }
}

@media (min-width: 768px) {
    .bottom-nav-icon { font-size: 1.5rem; }
    .bottom-nav-label { font-size: 0.75rem; }
    .bottom-nav-btn { padding: 0.5rem 0.6rem; gap: 0.25rem; }
    .bottom-nav-icon-wrap { width: 2.8rem; height: 2.8rem; }
}

/* Push main content above floating nav */
#mainAppContent {
    padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0));
}

/* ============ APP PAGES ============ */
.app-page { display: none; }
.app-page.active-page { display: block; }

/* Page entry animation */
.app-page.active-page {
    animation: pageIn 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ SLIDER FIXES ============ */
/* Thumb value shown above slider */
.slider-thumb-value {
    display: block;
    text-align: center;
    font-weight: 700;
    color: #6366f1;
    font-size: 1.15rem;
    margin-bottom: 0.2rem;
    letter-spacing: 0.03em;
}

/* Hide slider labels on mobile — too cramped */
@media (max-width: 767px) {
    .slider-labels { display: none !important; }
    .slider-container { margin-bottom: 0.25rem !important; }
}

/* Manual time input row */
.manual-time-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}
.manual-time-row label {
    font-size: 0.85rem;
    margin-bottom: 0;
    white-space: nowrap;
    min-width: fit-content;
}
.manual-time-input {
    width: 7rem !important;
    padding: 0.4rem 0.6rem !important;
    font-size: 0.9rem !important;
    text-align: center;
    font-family: monospace, 'BYekan', sans-serif;
}

/* ============================================================
   SAVED PLANS PAGE
   ============================================================ */

.saved-page-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.saved-plans-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}
.saved-plans-empty .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 0.75rem;
}

.saved-plan-card {
    background: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 1.25rem;
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(99,102,241,0.06);
    transition: transform 0.18s, box-shadow 0.18s;
    position: relative;
    overflow: hidden;
}
.saved-plan-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 0 1.25rem 1.25rem 0;
}
@media (min-width: 768px) {
    .saved-plan-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(99,102,241,0.12);
    }
}

.saved-plan-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.4rem;
}

.plan-meta {
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 0.85rem;
    line-height: 1.6;
}

.plan-subjects-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}
.plan-subject-tag {
    background: #eef2ff;
    color: #4f46e5;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.plan-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.plan-actions button {
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
    border-radius: 0.6rem;
}
.btn-load-plan {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-edit-plan {
    background: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #e5e7eb !important;
}
.btn-delete-plan {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca !important;
}

/* ============================================================
   STUDY TIME PAGE
   ============================================================ */

.studytime-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.studytime-header p {
    color: #6b7280;
    font-size: 0.88rem;
    margin-top: 0.4rem;
}

/* Plan selector */
.plan-selector-bar {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.plan-selector-bar label {
    font-size: 0.85rem;
    margin: 0;
    color: #4b5563;
    white-space: nowrap;
}
.plan-selector-bar select {
    flex: 1;
    min-width: 150px;
    font-size: 0.85rem;
    padding: 0.45rem 0.65rem;
}

/* Subject input rows */
.study-subject-input-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.study-subject-input-card .subject-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}
.subject-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.study-subject-input-card .subject-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.study-subject-input-card .subject-target {
    font-size: 0.72rem;
    color: #9ca3af;
    margin-top: 0.1rem;
}
.study-subject-input-card input {
    width: 5.5rem !important;
    text-align: center;
    font-family: monospace, 'BYekan', sans-serif;
    font-size: 1rem !important;
    font-weight: 700;
    padding: 0.4rem 0.5rem !important;
    flex-shrink: 0;
}

/* Save button */
.save-studytime-btn {
    width: 100%;
    padding: 0.85rem !important;
    font-size: 1rem !important;
    background: linear-gradient(135deg, #6366f1, #8b5cf6) !important;
    color: white !important;
    border: none !important;
    border-radius: 1rem !important;
    box-shadow: 0 4px 15px rgba(99,102,241,0.35);
    margin-top: 0.5rem;
}

/* Analytics section */
.analytics-section {
    margin-top: 1.5rem;
}

.analytics-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.analytics-stat-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.75rem 0.5rem;
    text-align: center;
}
.analytics-stat-card .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: #4f46e5;
}
.analytics-stat-card .stat-label {
    font-size: 0.68rem;
    color: #6b7280;
    margin-top: 0.2rem;
}

/* Chart canvas wrapper */
.chart-canvas-wrap {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

/* Legend */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    justify-content: center;
    margin-top: 0.75rem;
}
.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: #374151;
}
.chart-legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* Day adherence bar */
.adherence-bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}
.adherence-bar-row .adh-label {
    min-width: 5rem;
    color: #374151;
    text-align: right;
    font-size: 0.78rem;
}
.adherence-bar-wrap {
    flex: 1;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.adherence-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
}
.adherence-bar-row .adh-pct {
    min-width: 3rem;
    text-align: left;
    font-weight: 700;
    color: #6366f1;
    font-size: 0.78rem;
}


/* ============================================================
   MY STATS PAGE (آمار مطالعه من)
   ============================================================ */

.mystats-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.mystats-header p {
    color: #6b7280;
    font-size: 0.88rem;
    margin-top: 0.4rem;
}

.mystats-overview-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
}
@media (min-width: 480px) {
    .mystats-overview-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .mystats-overview-grid { grid-template-columns: repeat(6, 1fr); }
}

.mystats-stat-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.75rem 0.4rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(99,102,241,0.05);
}
.mstat-icon { font-size: 1.4rem; margin-bottom: 0.2rem; }
.mstat-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #4f46e5;
    line-height: 1.1;
}
.mstat-lbl {
    font-size: 0.62rem;
    color: #9ca3af;
    margin-top: 0.2rem;
    line-height: 1.2;
}

/* Progress bars */
.overall-progress-card {
    border: 1.5px solid #e5e7eb;
    border-radius: 1rem;
    padding: 1rem;
    margin-bottom: 1rem;
}
.progress-subject-row {
    margin-bottom: 0.9rem;
}
.progress-sub-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}
.progress-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}
.progress-sub-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.progress-sub-pct {
    font-size: 0.85rem;
    font-weight: 800;
}
.progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
    min-width: 2px;
}
.progress-sub-times {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

/* Subject detail stat cards */
.subject-stat-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}
.subject-stat-name {
    font-size: 0.9rem;
    font-weight: 800;
    margin-bottom: 0.6rem;
}
.subject-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}
@media (min-width: 480px) {
    .subject-stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.sstat-item {
    text-align: center;
    background: #f9fafb;
    border-radius: 0.6rem;
    padding: 0.4rem 0.3rem;
}
.sstat-val {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
    color: #374151;
}
.sstat-lbl {
    display: block;
    font-size: 0.62rem;
    color: #9ca3af;
    margin-top: 0.1rem;
}

/* Heatmap */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-bottom: 0.75rem;
}
@media (min-width: 480px) {
    .heatmap-grid { grid-template-columns: repeat(15, 1fr); }
}
.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.1s;
}
.heatmap-cell span {
    font-size: 0.6rem;
    color: rgba(0,0,0,0.3);
    line-height: 1;
}
.heatmap-cell:hover { transform: scale(1.15); }
.heatmap-today {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
}
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}
.heatmap-leg-cell {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* Leave months grid */
.leave-months-grid {
    display: grid;
    gap: 0.75rem;
}
@media (min-width: 600px) {
    .leave-months-grid { grid-template-columns: repeat(3, 1fr); }
}
.leave-month-card {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 1rem;
    padding: 0.85rem;
}
.leave-month-current {
    border-color: #6366f1;
    background: #eef2ff;
}
.leave-month-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.5rem;
}
.leave-month-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    font-size: 0.78rem;
    color: #6b7280;
    margin-bottom: 0.4rem;
}
.leave-days-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}
.leave-day-badge {
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.68rem;
    color: #713f12;
}

/* ============================================================
   LEAVE SECTION (in Study Time page)
   ============================================================ */

.leave-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.leave-balance-info {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 0.75rem;
}
.leave-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.5rem 0.85rem;
    min-width: 4rem;
}
.leave-stat-val {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.1;
}
.leave-stat-lbl {
    font-size: 0.65rem;
    color: #9ca3af;
    margin-top: 0.1rem;
    white-space: nowrap;
}

.leave-progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.leave-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #16a34a);
    transition: width 0.5s ease;
}

.leave-warning {
    text-align: center;
    color: #dc2626;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.take-leave-btn {
    width: 100%;
    padding: 0.85rem !important;
    font-size: 1rem !important;
    background: linear-gradient(135deg, #22c55e, #16a34a) !important;
    color: white !important;
    border: none !important;
    border-radius: 1rem !important;
    box-shadow: 0 4px 15px rgba(34,197,94,0.3);
    cursor: pointer;
    transition: opacity 0.2s;
}
.take-leave-btn:active { opacity: 0.8; }
.cancel-leave-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    box-shadow: 0 4px 15px rgba(239,68,68,0.3) !important;
}
.disabled-leave-btn {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ============================================================
   RESPONSIVE IMPROVEMENTS
   ============================================================ */

/* Bottom nav: 4 items support */
.bottom-nav {
    /* Already has display:flex; just ensure it handles 4 items */
}
.bottom-nav-btn {
    flex: 1;
    min-width: 0;
}
.bottom-nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Table responsive */
@media (max-width: 480px) {
    .table-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    #studyPlanTable td, #studyPlanTable th {
        min-width: 80px;
        font-size: 0.7rem;
        padding: 0.4rem 0.35rem;
    }
    .main-buttons {
        flex-direction: column;
    }
    .main-buttons button {
        width: 100%;
    }
}

/* Card section responsive */
@media (max-width: 380px) {
    .container {
        padding: 1rem;
        border-radius: 1rem;
    }
    .card-section {
        padding: 0.75rem;
    }
    .mystats-overview-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bottom-nav-label { font-size: 0.55rem; }
    .bottom-nav-icon-wrap { width: 2rem; height: 2rem; }
}

/* Study time page responsive fix */
@media (max-width: 360px) {
    .study-subject-input-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .study-subject-input-card input {
        width: 100% !important;
    }
    .analytics-summary-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.4rem;
    }
    .analytics-stat-card .stat-value { font-size: 1rem; }
}


/* Leave day in study plan table */
.leave-day-row td {
    background: #fef9c3 !important;
    color: #92400e !important;
}
.leave-day-cell {
    color: #92400e;
    font-weight: 700;
    font-size: 0.82rem;
}
