/* ============================================================
   RESET & BASE
   ============================================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 1rem;
    gap: 1.25rem;
}

/* ============================================================
   TABLE WRAPPERS
   ============================================================ */
.table-wrapper {
    max-width: 600px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(0, 20, 30, 0.10);
    padding: 1.25rem 1.25rem 1.5rem;
    transition: 0.2s;
}

/* Login wrapper is slightly narrower */
.login-wrapper {
    max-width: 420px;
}

/* ============================================================
   LOGIN SECTION
   ============================================================ */
.login-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #0b2b3c;
    margin: 0 0 0.1rem 0;
    text-align: center;
    letter-spacing: -0.2px;
    padding: 1.25rem 1.25rem 1.5rem;
}

.login-subtitle {
    font-size: 0.8rem;
    color: #5a7a8a;
    text-align: center;
    margin-bottom: 1rem;
    font-weight: 400;
}

.login-error {
    color: #c0392b;
    background: #fde8e8;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    margin: 0 0 0.75rem 0;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.75rem;
    color: #1b3b4f;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.7rem;
    border: 1.5px solid #dce6ed;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fafcfe;
    transition: border 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #1b3b4f;
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(27, 59, 79, 0.08);
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-login {
    background: #1b3b4f;
    color: white;
    border: none;
    padding: 0.5rem 1.8rem;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-transform: uppercase;
}

.btn-login:hover {
    background: #0f2a3a;
}

.btn-login:active {
    transform: scale(0.97);
}

.forgot-link {
    color: #1b3b4f;
    font-size: 0.75rem;
    text-decoration: none;
    opacity: 0.65;
    transition: opacity 0.2s;
}

.forgot-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ============================================================
   PROJECT TABLE
   ============================================================ */
.table-wrapper h2 {
    margin: 0 0 1rem 0;
    font-weight: 600;
    font-size: 1.3rem;
    letter-spacing: -0.3px;
    color: #0b2b3c;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

thead {
    background: #1b3b4f;
    color: white;
}

th {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 0.7rem;
    padding: 0.7rem 0.8rem;
    text-align: left;
    background: #1b3b4f;
    color: #f0f9ff;
}

td {
    padding: 0.7rem 0.8rem;
    border-bottom: 1px solid #eef3f7;
    vertical-align: middle;
    background: lightyellow;
}

th:first-child {
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds "..." when text is cut off */
}

td:first-child {
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis; /* Adds "..." when text is cut off */
}


tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: #f6faff;
}

.project-title {
    font-weight: 600;
    color: #0a2635;
    font-size: 0.85rem;
    white-space: nowrap;
    max-width: 200px;
}

.dept-tag {
    background: #d4e2ed;
    border-radius: 40px;
    padding: 0.15rem 0.7rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #1b3b4f;
    display: inline-block;
    white-space: nowrap;
    text-transform: uppercase;
}

.acronym {
    font-weight: 700;
    color: #003153;
    display: inline-block;
    margin-right: 4px;
    font-size: 0.85rem;
}

/* ============================================================
   LEGEND
   ============================================================ */
.legend {
    margin-top: 1.2rem;
    font-size: 0.7rem;
    color: #3f6279;
    border-top: 1px solid #e6edf3;
    padding-top: 1rem;
    display: flex;
    justify-content: flex-start;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.legend-tag {
    background: #d4e2ed;
    padding: 0.05rem 0.5rem;
    border-radius: 40px;
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.2px;
    color: #1b3b4f;
    margin-right: 2px;
}

/* ============================================================
   MOBILE FIRST — COMPACT & TOUCH-FRIENDLY
   ============================================================ */
@media (max-width: 600px) {
    body {
        padding: 0.75rem;
        gap: 1rem;
    }

    .table-wrapper {
        padding: 1rem 0.9rem 1.25rem;
        border-radius: 16px;
        max-width: 100%;
    }

    .login-wrapper {
        max-width: 100%;
    }

    .login-title {
        font-size: 1rem;
    }

    .login-subtitle {
        font-size: 0.7rem;
        margin-bottom: 0.75rem;
    }

    .form-group input,
    .form-group select {
        padding: 0.6rem 0.7rem;
        font-size: 1rem; /* prevents iOS zoom */
        border-radius: 8px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .btn-login {
        width: 100%;
        text-align: center;
        padding: 0.6rem;
        font-size: 0.85rem;
    }

    .forgot-link {
        text-align: center;
        font-size: 0.8rem;
    }

    /* Project table on mobile */
    .table-wrapper h2 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    th {
        font-size: 0.6rem;
        padding: 0.5rem 0.5rem;
    }

    td {
        padding: 0.5rem 0.5rem;
        font-size: 0.75rem;
    }

    .project-title {
        font-size: 0.75rem;
    }

    .acronym {
        font-size: 0.75rem;
    }

    .dept-tag {
        font-size: 0.55rem;
        padding: 0.1rem 0.5rem;
    }

    .legend {
        font-size: 0.6rem;
        gap: 0.6rem;
        padding-top: 0.75rem;
        margin-top: 0.75rem;
        justify-content: center;
    }

    .legend-tag {
        font-size: 0.55rem;
        padding: 0.05rem 0.4rem;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    body {
        padding: 0.4rem;
        gap: 0.75rem;
    }

    .table-wrapper {
        padding: 0.75rem 0.6rem 1rem;
        border-radius: 12px;
    }

    th,
    td {
        padding: 0.4rem 0.35rem;
        font-size: 0.65rem;
    }

    .project-title {
        font-size: 0.65rem;
    }

    .acronym {
        font-size: 0.65rem;
        display: block;
        margin-bottom: 1px;
    }

    .dept-tag {
        font-size: 0.5rem;
        padding: 0.05rem 0.4rem;
    }

    .login-title {
        font-size: 0.9rem;
    }

    .form-group input,
    .form-group select {
        font-size: 0.9rem;
        padding: 0.5rem 0.6rem;
    }

    .btn-login {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
}

/* ============================================================
   UTILITY — keeps things tidy
   ============================================================ */
/* Remove extra spacing between wrappers */
.table-wrapper + .table-wrapper {
    margin-top: 0;
}

/* Small screen safe area */
@media (max-width: 480px) {
    .table-wrapper {
        border-radius: 14px;
    }
}


/* ============================================================
   USER HOME / SELECTION HEADER
   ============================================================ */
.selection-header {
    margin-bottom: 1.5rem;
}

.selection-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #0b2b3c;
    margin: 0 0 0.25rem 0;
    text-align: center;
}

.selection-subtitle {
    font-size: 0.9rem;
    color: #5a7a8a;
    text-align: center;
    margin: 0;
}

/* ============================================================
   PROJECT BUTTONS (improved for userhome)
   ============================================================ */
.project-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.project-form {
    width: 100%;
}

.project-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.2rem;
    background: #f6faff;
    border: 2px solid #dce6ed;
    border-radius: 12px;
    text-decoration: none;
    color: #0b2b3c;
    transition: all 0.2s;
    font-weight: 500;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
}

.project-btn:hover {
    background: #e8f0f7;
    border-color: #1b3b4f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 20, 30, 0.10);
}

.project-btn:active {
    transform: translateY(0);
}

.project-btn-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.project-btn-name {
    font-size: 0.95rem;
}

.selection-actions {
    display: flex;
    justify-content: center;
    padding-top: 0.5rem;
    gap: 1.5rem;
}

.logout-link {
    color: #7a9aaa;
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s;
}

.logout-link:hover {
    color: #c0392b;
    text-decoration: underline;
}

/* Mobile styles */
@media (max-width: 600px) {
    .selection-title {
        font-size: 1.2rem;
    }

    .project-btn {
        padding: 0.7rem 1rem;
    }

    .project-btn-name {
        font-size: 0.85rem;
    }
}

/* ============================================================
   USER HOME / SELECTION STYLES
   ============================================================ */

/* Selection wrapper - narrower than the main wrapper */
.selection-wrapper {
    max-width: 500px;
}

/* Header section */
.selection-header {
    margin-bottom: 1.5rem;
}

.selection-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #0b2b3c;
    margin: 0 0 0.25rem 0;
    text-align: center;
}

.selection-subtitle {
    font-size: 0.9rem;
    color: #5a7a8a;
    text-align: center;
    margin: 0;
}

/* Project buttons container */
.project-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Form wrapper for each button */
.project-form {
    width: 100%;
}

/* Individual project button */
.project-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.2rem;
    background: #f6faff;
    border: 2px solid #dce6ed;
    border-radius: 12px;
    text-decoration: none;
    color: #0b2b3c;
    transition: all 0.2s ease;
    font-weight: 500;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
}

.project-btn:hover {
    background: #e8f0f7;
    border-color: #1b3b4f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 20, 30, 0.10);
}

.project-btn:active {
    transform: translateY(0);
}

/* Project button icon */
.project-btn-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Project button text */
.project-btn-name {
    font-size: 0.95rem;
}

/* Selection actions (logout) */
.selection-actions {
    display: flex;
    justify-content: center;
    padding-top: 0.5rem;
}

.logout-link {
    color: #7a9aaa;
    font-size: 0.8rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

.logout-link:hover {
    color: #c0392b;
    text-decoration: underline;
}

/* ============================================================
   RESPONSIVE STYLES FOR USER HOME
   ============================================================ */

@media (max-width: 600px) {
    .selection-title {
        font-size: 1.2rem;
    }

    .project-btn {
        padding: 0.7rem 1rem;
    }

    .project-btn-name {
        font-size: 0.85rem;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .selection-title {
        font-size: 1rem;
    }

    .project-btn {
        padding: 0.6rem 0.8rem;
    }

    .project-btn-icon {
        font-size: 1rem;
    }

    .project-btn-name {
        font-size: 0.75rem;
    }
}

/* Database Status Notification */
.db-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: Arial, sans-serif;
}

.db-status.up {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.db-status.down {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    animation: db-pulse 1.5s infinite;
}

@keyframes db-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Optional: Add a small status dot */
.db-status .status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.db-status.up .status-dot {
    background: #28a745;
}

.db-status.down .status-dot {
    background: #dc3545;
    animation: db-pulse 1.5s infinite;
}

