/* --- GLOBAL STYLES & VARIABLES --- */
:root {
    --primary: #1a73e8;
    --primary-dark: #0d47a1;
    --secondary: #dc3545;
    --text: #202124;
    --text-light: #5f6368;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --border: #e0e0e0;
    --hover: #f1f3f4;
    --success-bg: #e6f4ea;
    --danger-bg: #fce8e6;
    --info-bg: #e8f0fe;
    --warning-bg: #feefc3;
    --success-text: #137333;
    --danger-text: #c5221f;
    --info-text: #1967d2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

body, html {
    height: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.page {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}
.page.active {
    display: flex;
}

.demo-banner {
    background-color: var(--warning-bg);
    color: var(--text);
    text-align: center;
    padding: 0.5rem;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.demo-banner .info-button {
    background: none;
    border: none;
    color: var(--info-text);
    font-size: 1.1em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.demo-banner .info-button:hover {
    color: var(--primary);
}

/* --- LOGIN & ADD USER PAGE STYLES --- */
#login-page, #add-user-page {
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(-45deg, #e3f2fd, #e8f0fe, #e1f5fe, #f5f7fa);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-container, .form-container {
    width: 100%;
    max-width: 500px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    text-align: center;
}

.login-header, .form-header {
    background: linear-gradient(120deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 2.2rem 1.5rem;
}

.login-header h1, .form-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.login-header p, .form-header p {
    font-size: 1.1rem;
    opacity: 0.95;
}

.login-body, .form-body {
    padding: 2.5rem;
}

.form-group {
    margin-bottom: 1.4rem;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-light);
    font-size: 1rem;
}

input[type="text"], input[type="password"], input[type="number"], select {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

button {
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.login-body button, .form-body button {
    width: 100%;
    padding: 1rem;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-body button:hover, .form-body button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.3);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.95rem;
    margin-top: 1rem;
}

.login-footer, .form-footer {
    padding: 1.2rem;
    background-color: #fafafa;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-light);
}
.login-footer a, .form-footer a {
    color: var(--primary);
    text-decoration: none;
}

/* --- DASHBOARD SHARED STYLES --- */
header {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 34px;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
}

nav ul {
    display: flex;
    list-style: none;
    gap: 1.5rem;
}

nav a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

nav a:hover, nav a.active {
    color: var(--primary);
    background-color: var(--hover);
}

nav a.logout { color: var(--secondary); }
nav a.logout:hover { background-color: var(--danger-bg); }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; }


.dashboard-main {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 1200px;
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
    overflow: hidden;
}

.dashboard-header {
    background: linear-gradient(120deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 2.2rem 2rem;
    text-align: center;
}

.dashboard-header h1 {
    font-size: 2.1rem;
    margin-bottom: 0.5rem;
}

.dashboard-header p {
    font-size: 1.05rem;
    opacity: 0.9;
}

.content-section {
    padding: 2rem;
    border-bottom: 1px solid var(--border);
}
.content-section:last-child { border-bottom: none; }

.section-title {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.section-header > .section-title { margin-bottom: 0; }

.flash-messages-container {
    list-style: none;
    padding: 0;
    margin: 0;
}
.flash-messages-container:not(:empty) {
    margin-bottom: 1.2rem;
}

.flash-messages li {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    font-weight: 500;
    text-align: center;
    border: 1px solid transparent;
}
.danger { background-color: var(--danger-bg); color: var(--danger-text); border-color: #fad2cf; }
.success { background-color: var(--success-bg); color: var(--success-text); border-color: #c4e9d1; }
.info { background-color: var(--info-bg); color: var(--info-text); border-color: #d2e3fc; }

.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: 0.9rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background-color: #f8f9fa; font-weight: 600; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background-color: var(--hover); }

.flagged-item td { background-color: var(--danger-bg); color: var(--danger-text); }
.flagged-item:hover td { background-color: #f9d8d6; }

/* --- MANAGER DASHBOARD SPECIFIC --- */
.action-section {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 1.5rem;
    background-color: #f9fbfd;
    border: 1px solid var(--info-bg);
    border-radius: 8px;
    margin-bottom: 1.8rem;
    align-items: center;
    justify-content: center;
}

.action-button {
    text-decoration: none;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 0.75rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.action-button.logout { background: linear-gradient(135deg, var(--secondary), #a71e2a); }

.file-upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center;}
.file-upload input[type="file"] { border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem; }
.actions { display: flex; gap: 8px; }

.worker-inventory { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 1rem; overflow: hidden; }
.worker-header { background-color: #fafafa; padding: 1rem 1.5rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.worker-header:hover { background-color: var(--hover); }
.worker-table-container { display: none; padding: 1.5rem; }

.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 1.5rem; }
.pagination a { text-decoration: none; color: var(--primary); padding: 0.5rem 0.9rem; border: 1px solid var(--border); border-radius: 6px; }
.pagination .current-page { background-color: var(--primary); color: white; border-color: var(--primary); }

/* --- WORKER DASHBOARD SPECIFIC --- */
.add-item-form form { display: grid; grid-template-columns: 1fr; gap: 1.2rem; }
.add-item-form .form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.add-item-form .form-group { display: flex; flex-direction: column; }
.add-item-form input { padding: 0.8rem; font-size: 1rem; }

.btn-submit {
    padding: 0.9rem;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    justify-self: center;
    width: fit-content;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.inline-edit { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
.actions-cell { display: flex; gap: 8px; align-items: center; }
.btn-action { padding: 0.5rem 0.8rem; border-radius: 5px; font-weight: 500; font-size: 0.9rem; display: flex; gap: 6px; }
.btn-update { background-color: var(--primary); color: white; }
.btn-delete { border: 1px solid var(--secondary); color: var(--secondary); background: transparent; }
.btn-delete:hover { background-color: var(--secondary); color: white; }

/* --- MODAL STYLES --- */
.modal { display: none; position: fixed; z-index: 1001; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); }
.modal-content { background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; width: 80%; max-width: 600px; border-radius: 8px; }
.close { color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer; }

/* --- FOOTER --- */
footer {
    background: #1a1a1a;
    color: #bdc1c6;
    padding: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    margin-top: auto;
}

/* --- RESPONSIVE STYLES --- */
@media (max-width: 768px) {
    .header-container { flex-direction: column; align-items: stretch; }
    .content-section { padding: 1.2rem; }
    .action-section { flex-direction: column; align-items: stretch; }
    .file-upload { flex-direction: column; align-items: stretch; } /* This is the key fix */
    .file-upload > * { width: 100%; text-align: center; } /* Makes button and input full width */
    .add-item-form .form-row { grid-template-columns: 1fr; }
    .mobile-menu-btn { display: block; position: absolute; top: 1rem; right: 1.5rem; }
    nav ul { display: none; flex-direction: column; width: 100%; padding: 0.8rem 0; }
    nav ul.active { display: flex; }
}