:root {
    --primary-red: #d32f2f;
    --primary-white: #ffffff;
    --accent-yellow: #fbc02d;
    --accent-black: #212121;
    --bg-dark: #121212;
    --text-white: #e0e0e0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, var(--primary-red), #8e0000);
    padding: 1.5rem 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--primary-white);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.yellow-text {
    color: var(--accent-yellow);
}

.container {
    width: 95%;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.login-container {
    width: 100%;
    max-width: 400px;
    margin: auto;
    padding: 3rem;
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    text-align: center;
}

.login-container h2 {
    color: var(--accent-yellow);
    margin-bottom: 2rem;
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 15px;
    margin: 10px 0;
    display: inline-block;
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    outline: none;
    transition: 0.3s;
}

input:focus {
    border-color: var(--accent-yellow);
    background: rgba(255, 255, 255, 0.15);
}

button,
.btn {
    background: linear-gradient(135deg, var(--accent-yellow), #f9a825);
    color: var(--accent-black);
    padding: 12px 25px;
    margin: 15px 0;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    transition: 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: inline-block;
}

button:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(251, 192, 45, 0.4);
}

.secondary {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--primary-red) !important;
    color: white !important;
}

.secondary:hover {
    background: var(--primary-red) !important;
    color: white !important;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    margin-top: 1rem;
}

th {
    background: var(--primary-red);
    color: white;
    padding: 15px;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

th:first-child {
    border-radius: 10px 0 0 10px;
}

th:last-child {
    border-radius: 0 10px 10px 0;
}

td {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    transition: 0.3s;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.08);
}

td:first-child {
    border-radius: 10px 0 0 10px;
}

td:last-child {
    border-radius: 0 10px 10px 0;
}

.sub-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.category-label {
    background: var(--primary-red);
    color: white;
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 5px;
}

.applicant-list {
    margin-bottom: 15px;
}

.applicant-item {
    margin-bottom: 5px;
    padding-left: 10px;
    border-left: 2px solid var(--accent-yellow);
}

.btn-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-group-horizontal {
    display: flex;
    gap: 8px;
}

.mini-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    width: auto;
    margin: 2px;
    display: inline-block;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}

.mini-btn:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.mini-btn.uploaded {
    background: #4CAF50;
    color: white;
    border: 1px solid #45a049;
}

.mini-btn.uploaded:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-1px);
}

.template-section {
    margin-top: 3rem;
}

.template-buttons {
    display: flex;
    gap: 20px;
    margin-top: 1rem;
}

.admin-link {
    color: var(--accent-yellow);
    text-decoration: none;
    font-weight: bold;
    border: 1px solid var(--accent-yellow);
    padding: 8px 15px;
    border-radius: 8px;
    transition: 0.3s;
}

.admin-link:hover {
    background: var(--accent-yellow);
    color: var(--accent-black);
}

/* Scrollable Table Container */
.table-scroll {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.table-scroll::-webkit-scrollbar {
    width: 6px;
}

.table-scroll::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.table-scroll::-webkit-scrollbar-thumb {
    background: var(--primary-red);
    border-radius: 10px;
}

/* Enhanced Mobile Responsive */
@media (max-width: 768px) {
    header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    h1 {
        font-size: 1.3rem;
        text-align: center;
        width: 100%;
        margin-bottom: 1rem;
    }

    .container {
        width: 95%;
        margin: 1rem auto;
        padding: 1rem;
    }

    .login-container {
        margin: 1rem;
        padding: 2rem 1.5rem;
    }

    /* Fix admin dashboard grid layout */
    .container > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Fix template management grid */
    .container > section[style*="grid-template-columns: repeat(3, 1fr)"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    /* Fix assignee checkboxes grid */
    div[style*="grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))"] {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* Fix index page table - eliminate horizontal scroll */
    .table-scroll {
        max-height: none;
        overflow-y: visible;
        overflow-x: hidden;
    }

    /* Transform index page table into stacked cards */
    .table-scroll table {
        font-size: 0.9rem;
        min-width: auto;
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
    }

    .table-scroll thead {
        display: none; /* Hide headers on mobile */
    }

    .table-scroll tbody {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .table-scroll tr {
        display: flex;
        flex-direction: column;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 15px;
        padding: 20px;
        margin-bottom: 15px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .table-scroll td {
        display: flex;
        flex-direction: column;
        padding: 15px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: 0.85rem;
        width: 100% !important;
    }

    .table-scroll td:last-child {
        border-bottom: none;
    }

    /* Add labels for index page table data */
    .table-scroll td:before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--accent-yellow);
        margin-bottom: 10px;
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Special handling for applicant lists in mobile */
    .applicant-list {
        margin-top: 10px;
    }

    .applicant-item {
        padding: 8px 12px;
        margin-bottom: 5px;
        background: rgba(255, 255, 255, 0.08);
        border-radius: 8px;
        border-left: 3px solid var(--accent-yellow);
    }

    /* Fix assignee names display */
    .table-scroll td:nth-child(2) div {
        padding: 8px 12px;
        margin-bottom: 8px;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 6px;
        min-height: auto !important;
    }

    /* Fix view docs buttons */
    .table-scroll td:nth-child(3) div {
        margin-bottom: 12px;
        min-height: auto !important;
    }

    .table-scroll td:nth-child(3) button {
        width: 100%;
        margin-bottom: 8px;
        text-align: center;
        padding: 12px;
        font-size: 0.85rem;
    }

    /* Fix upload docs button groups */
    .btn-group-horizontal {
        flex-direction: column !important;
        gap: 8px !important;
        margin-bottom: 15px !important;
    }

    .btn-group-horizontal button {
        width: 100%;
        text-align: center;
        padding: 10px;
        font-size: 0.8rem;
        margin: 2px 0;
    }

    /* Fix template buttons */
    .template-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .template-buttons button {
        width: 100% !important;
        text-align: center;
    }

    /* Fix category labels */
    .category-label {
        font-size: 0.9rem;
        padding: 8px 15px;
        margin-bottom: 10px;
        text-align: center;
    }

    table {
        font-size: 0.8rem;
        min-width: 600px;
    }

    th, td {
        padding: 8px 4px;
        font-size: 0.75rem;
    }

    .btn-group-horizontal {
        flex-direction: column;
        gap: 5px;
    }

    .mini-btn {
        font-size: 0.7rem;
        padding: 8px 12px;
        width: 100%;
        text-align: center;
        margin: 2px 0;
    }

    button, .btn {
        width: 100%;
        padding: 12px;
    }

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

    .template-buttons button {
        width: 100% !important;
    }

    /* Fix navigation on mobile */
    header nav {
        justify-content: center;
        width: 100%;
    }

    header nav > div {
        flex-direction: column;
        width: 100%;
        margin-bottom: 1rem;
        align-items: center !important;
    }

    header nav > div:last-child {
        margin-bottom: 0;
    }

    .admin-link {
        width: 100%;
        text-align: center;
        display: block;
        margin-bottom: 5px;
    }

    /* Fix user info display */
    header nav > div > div:first-child {
        flex-direction: column;
        text-align: center;
        padding-right: 0 !important;
        border-right: none !important;
        padding-bottom: 10px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        margin-bottom: 10px;
    }

    /* Fix button groups in header */
    header nav > div > div:last-child {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    /* Fix modal dialogs for mobile */
    div[style*="position:fixed"][style*="width:400px"] {
        width: 90% !important;
        max-width: 350px;
        margin: 0 5%;
    }

    div[style*="position:fixed"][style*="width:450px"] {
        width: 90% !important;
        max-width: 400px;
        margin: 0 5%;
    }

    /* Fix notification popup */
    #notificationPopup {
        right: 10px !important;
        left: 10px !important;
        min-width: auto !important;
    }

    /* Fix form inputs on mobile */
    input[type="text"],
    input[type="password"],
    select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 15px;
    }

    /* Fix table action buttons in stacked layout */
    td div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 8px !important;
        width: 100%;
        margin-top: 5px;
    }

    /* Fix applicant document upload forms */
    form[style*="display: inline"] {
        display: block !important;
        width: 100%;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.1rem;
    }

    .container {
        padding: 0.75rem;
    }

    .login-container {
        padding: 1.5rem 1rem;
    }

    table {
        font-size: 0.7rem;
        min-width: 500px;
    }

    th, td {
        padding: 6px 3px;
        font-size: 0.65rem;
    }

    /* Fix assignee checkboxes on small screens */
    div[style*="grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Make modal dialogs even smaller on very small screens */
    div[style*="position:fixed"][style*="width:400px"],
    div[style*="position:fixed"][style*="width:450px"] {
        width: 95% !important;
        max-width: none;
        margin: 0 2.5%;
        padding: 20px !important;
    }

    /* Improve button spacing on very small screens */
    .mini-btn {
        font-size: 0.65rem;
        padding: 10px 8px;
        margin: 1px 0;
    }

    /* Fix header user info on very small screens */
    header nav > div > div:first-child {
        font-size: 0.9rem;
    }

    header nav > div > div:first-child span {
        font-size: 0.6rem !important;
    }

    /* Fix admin links on very small screens */
    .admin-link {
        font-size: 0.7rem;
        padding: 8px 10px;
    }

    /* Fix form padding on very small screens */
    form[style*="padding: 20px"] {
        padding: 15px !important;
    }

    /* Fix template sections on very small screens */
    div[style*="padding: 20px"][style*="text-align: center"] {
        padding: 15px !important;
    }

    /* Fix table scroll on very small screens - no horizontal scroll */
    .table-scroll {
        max-height: none;
        overflow-y: visible;
        overflow-x: hidden;
    }

    /* Ensure stacked table layout on very small screens */
    .table-scroll table {
        font-size: 0.8rem;
        min-width: auto;
        width: 100%;
    }

    .table-scroll thead {
        display: none;
    }

    .table-scroll tbody {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .table-scroll tr {
        display: flex;
        flex-direction: column;
        padding: 15px;
        margin-bottom: 12px;
    }

    .table-scroll td {
        display: flex;
        flex-direction: column;
        padding: 12px 0;
        font-size: 0.8rem;
        width: 100% !important;
    }

    .table-scroll td:before {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }

    /* Fix applicant items on very small screens */
    .applicant-item {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    /* Fix buttons on very small screens */
    .btn-group-horizontal button {
        font-size: 0.75rem;
        padding: 8px;
    }

    .mini-btn {
        font-size: 0.65rem;
        padding: 10px 8px;
        margin: 1px 0;
    }

    table {
        font-size: 0.7rem;
        min-width: 500px;
    }

    th, td {
        padding: 6px 3px;
        font-size: 0.65rem;
    }

    /* Fix assignee checkboxes on small screens */
    div[style*="grid-template-columns: repeat(auto-fill, minmax(150px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Make modal dialogs even smaller on very small screens */
    div[style*="position:fixed"][style*="width:400px"],
    div[style*="position:fixed"][style*="width:450px"] {
        width: 95% !important;
        max-width: none;
        margin: 0 2.5%;
        padding: 20px !important;
    }

    /* Improve button spacing on very small screens */
    .mini-btn {
        font-size: 0.65rem;
        padding: 10px 8px;
        margin: 1px 0;
    }

    /* Fix header user info on very small screens */
    header nav > div > div:first-child {
        font-size: 0.9rem;
    }

    header nav > div > div:first-child span {
        font-size: 0.6rem !important;
    }

    /* Fix admin links on very small screens */
    .admin-link {
        font-size: 0.7rem;
        padding: 8px 10px;
    }

    /* Fix form padding on very small screens */
    form[style*="padding: 20px"] {
        padding: 15px !important;
    }

    /* Fix template sections on very small screens */
    div[style*="padding: 20px"][style*="text-align: center"] {
        padding: 15px !important;
    }

    /* Hide some less critical elements on very small screens */
    .category-label {
        font-size: 0.7rem;
        padding: 3px 8px;
    }

    /* Ensure no horizontal overflow on very small screens */
    body {
        overflow-x: hidden;
    }

    .container {
        overflow-x: hidden;
    }

    /* Fix any remaining overflow issues */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
}