/* ===== GLOBAL STYLES ===== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
    padding-bottom: 90px;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 500;
}

h1 {
    margin: 0;
    font-size: 1.5rem;
}

h2 {
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

h3 {
    margin: 0;
    color: #34495e;
}

h4 {
    margin: 0 0 10px 0;
    color: #7f8c8d;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 15px;
}

.hidden {
    display: none !important;
}

/* ===== PAGES ===== */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== INFO BOX ===== */
.info-box {
    background-color: #e8f4fc;
    padding: 15px;
    border-radius: 5px;
    border-left: 5px solid #3498db;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ===== COLUMNS LAYOUT ===== */
.columns {
    display: flex;
    gap: 20px;
}

.column {
    flex: 1;
}

/* ===== FORM ELEMENTS ===== */
textarea {
    width: 100%;
    height: 200px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    resize: vertical;
    font-family: monospace;
    box-sizing: border-box;
}

select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    min-width: 150px;
    font-size: 1rem;
    cursor: pointer;
    background: white;
}

input[type="text"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
    font-size: 1rem;
}

::placeholder {
    color: #bdc3c7;
    opacity: 1;
}

/* ===== CONTROLS ===== */
.controls {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

/* ===== CLASS MANAGEMENT ===== */
.class-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.btn-new-class {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
}

.btn-new-class:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.4);
}

.class-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.class-item {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 5px solid #3498db;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.class-item:hover {
    background: #f8f9fa;
    transform: translateX(5px);
}

.class-item.selected {
    border-left-color: #2ecc71;
    background: #e8f8f0;
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.2);
}

.class-item-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
}

.class-item-count {
    color: #95a5a6;
    font-size: 0.9rem;
}

.class-editor {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
    margin-top: 20px;
}

.class-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.btn-delete-class {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-class:hover {
    transform: scale(1.05);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #95a5a6;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

/* Auto-save info */
.auto-save-info {
    margin-top: 15px;
    text-align: center;
    color: #27ae60;
    font-size: 0.9rem;
    font-style: italic;
}

/* ===== STUDENT ROWS ===== */
.student-row {
    background: white;
    padding: 4px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    border-left: 6px solid #ccc;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-wrap: nowrap;
    gap: 10px;
}

.student-row.male {
    border-left-color: #3498db;
}

.student-row.female {
    border-left-color: #e91e63;
}

.student-row.selected {
    background-color: #fff9c4;
    border-left-color: #f1c40f;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
}

.student-row.dragging {
    opacity: 0.5;
    background-color: #f0f0f0;
}

.student-name {
    font-weight: 600;
    margin-right: 5px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 100px;
}

.drag-handle {
    cursor: grab;
    margin-right: 15px;
    color: #95a5a6;
    font-size: 1.2rem;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.selection-area {
    display: none;
    margin-right: 15px;
}

.selection-area.active {
    display: block;
}

.selection-checkbox {
    transform: scale(1.5);
    cursor: pointer;
}

.student-row-top {
    display: flex;
    align-items: center;
    width: 100%;
}

.input-area {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

/* ===== TIME INPUT ===== */
.time-input-group {
    display: flex;
    flex-direction: column;
}

.time-input-group label {
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 2px;
}

input.time-input {
    width: 130px;
    font-family: monospace;
    letter-spacing: 1px;
}

input.grade-input {
    width: 60px;
    font-weight: bold;
    background-color: #f9f9f9;
}

.extra-times {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    font-size: 0.75rem;
    color: #555;
    width: 100%;
}

.extra-time-box label {
    font-size: 0.7rem;
    color: #777;
    margin-bottom: 2px;
    display: block;
}

.extra-time-input {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-weight: bold;
    font-family: monospace;
    color: #2c3e50;
    width: 85px;
    font-size: 0.85rem;
    padding: 4px;
    text-align: center;
}

/* ===== HISTORY CONTROLS ===== */
.history-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 10px;
}

.btn-history {
    background: #ecf0f1;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
    height: 25px;
}

.btn-history.btn-delete {
    background-color: #fce4e4;
    color: #c0392b;
    border-color: #fab1a0;
    font-weight: bold;
}

.btn-history:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== STOPWATCH BUTTON ===== */
.btn-stopwatch {
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 140px;
}

.btn-stopwatch.start {
    background-color: #3498db;
    color: white;
}

.btn-stopwatch.stop {
    background-color: #e74c3c;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== BUTTONS ===== */
.btn-action {
    background-color: #27ae60;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin-top: 15px;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-action:hover {
    background-color: #219150;
}

.btn-export {
    background-color: #3498db;
}

.btn-warning {
    background-color: #e67e22;
}

.btn-row {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-bottom: 15px;
}

.btn-row .btn-action {
    margin: 0;
    flex: 1;
}

.btn-action-small {
    background-color: #95a5a6;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.9rem;
    flex: 1;
    transition: background 0.2s;
}

.btn-action-small:hover {
    background-color: #7f8c8d;
}

.entry-header-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.btn-mode {
    background-color: #8e44ad;
    color: white;
    padding: 15px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    flex: 1.5;
    font-size: 1.1rem;
    transition: transform 0.1s;
}

.btn-mode:active {
    transform: scale(0.98);
}

.btn-multi {
    background-color: #27ae60;
    color: white;
    padding: 15px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    flex: 1.5;
    font-size: 1.1rem;
    transition: transform 0.1s;
}

.btn-multi:active {
    transform: scale(0.98);
}

.btn-multi:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.select-all-container {
    height: 40px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.btn-select-all {
    background-color: #34495e;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
}

/* ===== TABLES ===== */
.editor-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-top: 10px;
}

.editor-table th,
.editor-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.editor-table th {
    background-color: #7f8c8d;
    color: white;
}

.editor-input {
    width: 100%;
    box-sizing: border-box;
    font-family: monospace;
    padding: 5px;
}

#resultsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#resultsTable th {
    background-color: #34495e;
    color: white;
    padding: 10px;
    text-align: left;
}

#resultsTable td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    margin-bottom: 20px;
    text-align: center;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    margin-bottom: 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: left;
}

.modal-content input[type="text"]:focus {
    border-color: #3498db;
    outline: none;
}

.modal-buttons {
    display: flex;
    gap: 10px;
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.btn-confirm {
    flex: 1;
    padding: 12px;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

/* ===== NAVIGATION ===== */
nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    z-index: 1000;
}

nav button {
    background: none;
    border: none;
    font-size: 0.9rem;
    color: #95a5a6;
    cursor: pointer;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

nav button.active {
    color: #2c3e50;
    background-color: #ecf0f1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .columns {
        flex-direction: column;
        gap: 10px;
    }

    .student-row {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 8px;
    }

    .student-row-top {
        justify-content: space-between;
    }

    .student-name {
        flex: 1;
        font-size: 1rem;
    }

    .input-area {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        justify-content: flex-start;
    }

    .mobile-row-break {
        flex-basis: 100% !important;
        width: 100% !important;
        height: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .time-input-group {
        flex: 1;
        min-width: 80px;
    }

    .btn-stopwatch {
        flex: 1.5;
        height: 55px !important;
        font-size: 1.2rem !important;
        min-width: 130px;
        padding: 10px;
        margin-top: 5px;
    }

    .extra-time-input,
    .grade-input {
        width: 100% !important;
        box-sizing: border-box;
    }

    .entry-header-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .class-management-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .btn-new-class {
        width: 100%;
    }
}

/* ===== GRADE SETTINGS BOX ===== */
.grade-settings-box {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    border-left: 5px solid #16a085;
}

.grade-settings-box h4 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.grade-mode-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.radio-option:hover {
    background: #f8f9fa;
}

.radio-option input[type="radio"] {
    transform: scale(1.2);
    cursor: pointer;
}

.radio-option span {
    font-size: 0.95rem;
    color: #34495e;
}

.weighting-controls {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.weighting-controls.hidden {
    display: none;
}

.weight-slider-group {
    margin-bottom: 12px;
}

.weight-slider-group label {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.weight-label {
    font-weight: 600;
    min-width: 130px;
    color: #2c3e50;
}

.weight-slider-group input[type="range"] {
    flex: 1;
    min-width: 150px;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.weight-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #16a085;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.weight-slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #16a085;
    cursor: pointer;
    border: none;
}

.weight-value {
    font-weight: bold;
    color: #16a085;
    min-width: 50px;
    text-align: right;
    font-size: 1.1rem;
}

.weight-presets {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-preset {
    padding: 8px 16px;
    background: #ecf0f1;
    border: 1px solid #bdc3c7;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: #34495e;
    transition: all 0.2s;
}

.btn-preset:hover {
    background: #16a085;
    color: white;
    border-color: #16a085;
}

.btn-pdf {
    background: linear-gradient(135deg, #16a085, #1abc9c);
    flex: 2;
}

.btn-pdf:hover {
    background: linear-gradient(135deg, #138d75, #16a085);
}

@media (max-width: 600px) {
    .grade-mode-toggle {
        flex-direction: column;
        gap: 10px;
    }

    .weight-slider-group label {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .weight-label {
        min-width: auto;
    }

    .weight-slider-group input[type="range"] {
        width: 100%;
    }

    .weight-value {
        text-align: left;
    }

    .btn-pdf {
        flex: 1;
        width: 100%;
    }
}