body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #f0f2f5;
    position: relative;
    overflow-x: hidden; /* Disable horizontal scrolling */
    overflow-y: auto; /* Enable vertical scrolling */
}

/* Top Navbar */
.top-navbar {
    background-color: #6b46c1;
    color: white;
    padding: 15px 20px;
    font-size: 1.5em;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.app-title {
    margin-left: 20px;
}

/* Secondary Navbar (Tabs) */
.secondary-navbar {
    background-color: #ffffff;
    padding: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    position: fixed;
    width: 100%;
    top: 60px; /* Below top-navbar */
    left: 0;
    z-index: 999;
}

.nav-tab {
    text-decoration: none;
    color: #333;
    font-size: 1.1em;
    font-weight: 500;
    padding: 15px 25px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    background-color: #e6e6e6;
}

.nav-tab.active {
    color: #6b46c1;
    border-bottom: 3px solid #6b46c1;
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    padding-top: 130px; /* Space for both navbars */
    padding-bottom: 60px; /* Space for footer */
    min-height: calc(100vh - 190px); /* Adjust height for content */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align content to top */
}

.container-card {
    background: #ffffff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 700px; /* Adjusted max-width for overall content */
    margin: 20px auto; /* Center the card and provide vertical spacing */
    box-sizing: border-box; /* Include padding in width */
}

h2 {
    color: #6b46c1;
    text-align: center;
    font-size: 1.8em;
    margin-bottom: 25px;
    font-weight: 600;
}

h3 {
    color: #333;
    font-size: 1.3em;
    margin-top: 30px;
    margin-bottom: 15px;
}

/* Input Group Styles */
.input-group {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.input-field {
    flex: 1;
}

.input-field label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

input[type="number"], input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    box-sizing: border-box;
}

input[type="number"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: #6b46c1;
    box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.2);
}

/* Button Styles */
button {
    background-color: #6b46c1;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1.1em;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    width: 100%;
    margin-top: 10px;
}

button:hover {
    background-color: #553c9a;
    transform: translateY(-2px);
}

/* Result Sections */
.result-section {
    margin-top: 25px;
    padding: 20px;
    border-radius: 8px;
    background-color: #f9f9f9;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.result-label {
    font-size: 1em;
    color: #777;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.result-value {
    font-size: 2.2em;
    font-weight: 700;
    color: #333;
}

.result-value .status {
    font-size: 0.5em;
    font-weight: 500;
    display: block;
    margin-top: 5px;
}

.result-value.good {
    color: #4CAF50; /* Green for good */
}

.result-value.low {
    color: #F44336; /* Red for low */
}

.result-value.yellow {
    color: #FFC107; /* Yellow for exactly 50% */
}

.result-value.error {
    color: #FF5722; /* Orange for error messages */
    font-size: 1.2em;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: #888;
    font-size: 0.9em;
    background-color: #f0f2f5;
    border-top: 1px solid #e0e0e0;
}

/* Multiple Subjects Page Specifics */
.num-subjects-control {
    margin-bottom: 25px;
    text-align: center;
}

.num-subjects-control label {
    display: block;
    margin-bottom: 10px;
    color: #555;
    font-weight: 500;
}

.number-input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.number-input-group button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5em;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.number-input-group input {
    width: 60px;
    text-align: center;
    font-size: 1.2em;
    font-weight: 600;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 8px;
    -moz-appearance: textfield; /* Firefox hide arrows */
}

/* Hide arrows for Chrome, Safari, Edge */
.number-input-group input::-webkit-outer-spin-button,
.number-input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.table-container {
    overflow-x: auto;
    margin-top: 20px;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    min-width: 600px; /* Ensure table is not too narrow on smaller screens */
}

th, td {
    border: 1px solid #eee;
    padding: 12px 15px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
    color: #6b46c1;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
}

tr:nth-child(even) {
    background-color: #f9f9f9;
}

tr:hover {
    background-color: #f1f1f1;
}

.attendance-display {
    font-weight: 600;
}

.attendance-display.good {
    color: #4CAF50;
}

.attendance-display.low {
    color: #F44336;
}

.attendance-display.yellow {
    color: #FFC107; /* Yellow for exactly 50% */
}

.attendance-display.error {
    color: #FF5722;
    font-weight: normal;
}

.overall-result {
    text-align: center;
    font-size: 1.5em;
    font-weight: 700;
    margin-top: 25px;
    padding: 15px;
    border-radius: 8px;
    background-color: #eaf4ff;
    color: #333;
}

.overall-result.good {
    background-color: #e8f5e9; /* Light green */
    color: #2E7D32; /* Darker green */
}

.overall-result.low {
    background-color: #ffebee; /* Light red */
    color: #C62828; /* Darker red */
}

.overall-result.yellow {
    background-color: #fffde7; /* Light yellow */
    color: #FF8F00; /* Darker yellow */
}

.overall-result.error {
    background-color: #ffebee; /* Light red */
    color: #C62828; /* Darker red */
}

/* Chart Container */
.chart-container {
    width: 100%;
    max-width: 600px; /* Max width for chart */
    height: 350px; /* Adjusted height for better visibility */
    margin: 30px auto 0; /* Center chart */
}

/* Responsive Design for smaller screens */
@media (max-width: 768px) {
    .top-navbar {
        padding: 10px 15px;
        font-size: 1.2em;
    }

    .secondary-navbar {
        padding: 0 10px;
        top: 50px; /* Adjust for smaller top navbar */
    }

    .nav-tab {
        font-size: 0.9em;
        padding: 12px 15px;
        gap: 5px;
    }

    .main-content {
        padding-top: 105px; /* Adjusted padding for smaller navbars */
    }

    .container-card {
        padding: 20px;
        margin: 15px;
    }

    .input-group {
        flex-direction: column;
        gap: 15px;
    }

    h2 {
        font-size: 1.5em;
    }

    h3 {
        font-size: 1.1em;
    }

    button {
        font-size: 1em;
    }

    .result-value {
        font-size: 1.8em;
    }

    .table-container {
        min-width: unset; /* Allow table to shrink on very small screens */
        width: 100%;
    }

    table, th, td {
        font-size: 0.9em;
        padding: 8px 10px;
    }

    .number-input-group button {
        width: 35px;
        height: 35px;
        font-size: 1.2em;
    }

    .number-input-group input {
        width: 50px;
        font-size: 1em;
    }

    .chart-container {
        height: 300px;
    }
}
