:root {
    --royal-green: #00603a;
    --royal-black: #000000;
    --dark-grey: #121212;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --error-red: #ff4d4d;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--royal-black);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
}

.navbar {
    padding: 1.5rem 5%;
    background-color: transparent;
    display: flex;
    align-items: center;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--royal-green);
    letter-spacing: 2px;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(45deg, var(--white), var(--royal-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: #a0a0a0;
    max-width: 600px;
    margin: 0 auto;
}

.upload-container {
    width: 100%;
    max-width: 600px;
}

.upload-form {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

.form-row {
    display: grid;
    /* Top row (semester + module) uses two equal columns; subject is moved to its own row */
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 1.5rem;
    align-items: start;
}

.form-row .form-group {
    margin-bottom: 0;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--royal-green);
}

/* Prevent labels from pushing layout and allow wrapping */
label {
    display: block;
    word-wrap: break-word;
    max-width: 100%;
}

select, input[type="text"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--white);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

/* Truncate long option text and ensure touch-friendly sizes */
select {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 30px; /* avoid overlap with native arrow */
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}

.form-row, .form-row .form-group {
    /* Prevent children from overflowing their grid/flex container */
    min-width: 0;
}

select option {
    background-color: var(--dark-grey);
    color: var(--white);
}

select:focus, input[type="text"]:focus {
    border-color: var(--royal-green);
    box-shadow: 0 0 0 2px rgba(0, 96, 58, 0.3);
}

.hidden {
    display: none !important;
}

#otherBranch, .manual-subject-container {
    margin-top: 0.8rem;
}

.manual-subject-container {
    display: flex;
    /* span the two columns now used by the form */
    grid-column: 1 / span 2;
    gap: 15px;
    width: 100%;
    margin-top: 15px;
    margin-bottom: 15px;
}

/* Subject row styling: make subject select span the full width of the form */
.subject-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 1.5rem;
}
.full-span {
    grid-column: 1 / -1;
}

.manual-subject-container input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--royal-green);
    color: var(--white);
    padding: 12px;
    border-radius: 8px;
    font-size: 1.05rem;
    transition: all 0.3s ease;
    outline: none;
}

#course-code {
    flex: 0 0 calc(20% - 7.5px); /* 20% width minus half the gap */
}

#course-name {
    flex: 1; /* Fills the remaining 80% */
}

#material-type-container {
    width: 100%;
    margin-top: 15px;
    margin-bottom: 15px;
}

#material-type {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--royal-green);
    padding: 0.8rem 1rem;
}

.drop-zone {
    border: 2px dashed var(--glass-border);
    padding: 2rem;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--royal-green);
    background: rgba(0, 96, 58, 0.05);
}

.drop-zone p span {
    color: var(--royal-green);
    text-decoration: underline;
}

.file-list {
    list-style: none;
    margin-top: 1rem;
}

.file-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.file-item .remove-file {
    color: var(--error-red);
    cursor: pointer;
    font-weight: bold;
}

#submitBtn {
    width: 100%;
    background-color: var(--royal-green);
    color: var(--white);
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

#submitBtn:hover {
    background-color: #007a4a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 96, 58, 0.4);
}

#submitBtn:active {
    transform: translateY(0);
}

/* Progress and Success states */
.progress-container {
    margin-top: 1.5rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--royal-green);
    transition: width 0.3s ease;
}

.success-message {
    margin-top: 1.5rem;
    background: rgba(0, 96, 58, 0.2);
    border: 1px solid var(--royal-green);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    color: #4ade80;
    font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .manual-subject-container {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
    #course-code {
        flex: 0 0 100%;
    }
}

/* Mobile-first improvements for smaller devices */
@media (max-width: 600px) {
    html, body {
        font-size: 16px; /* prevents auto-zoom on iOS */
    }

    main {
        padding-left: 20px;
        padding-right: 20px;
    }

    .upload-form {
        padding: 1.5rem;
        border-radius: 16px;
    }

    /* Full-width stacking of form elements */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    .subject-row { grid-template-columns: 1fr !important; }
    .manual-subject-container { flex-direction: column; gap: 12px; }

    /* Larger touch targets */
    select, input[type="text"], #material-type, .drop-zone, #submitBtn {
        min-height: 48px;
        font-size: 16px;
        padding: 12px 14px;
    }

    /* Dropzone text: show mobile text, hide desktop variant */
    .drop-text-desktop { display: none; }
    .drop-text-mobile { display: block; color: #cfcfcf; }

    /* Sticky submit button at bottom */
    #submitBtn {
        position: fixed;
        left: 20px;
        right: 20px;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
        z-index: 1200;
        border-radius: 14px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.5);
        height: 54px;
        padding: 0 20px;
        font-size: 17px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: auto;
        cursor: pointer;
    }

    /* Make sure form bottom spacing accounts for sticky button (including safe-area) */
    .upload-form { padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)); }

    /* Tweak hero header */
    .hero h1 { font-size: 2rem; }

    /* Center logo */
    .navbar { justify-content: center; padding: 1rem 20px; }
}

