/* General Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #1c1e21;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column; /* Default for non-login pages */
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto; /* Centers the container horizontally */
    padding: 20px 15px;
    flex-grow: 1;
}

a {
    color: #007bff;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    padding: 8px 15px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccd0d5;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 14px;
}

/* Site Header Styles */
.site-header {
    background-color: #ffffff;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.logo-area {
    display: flex;
    align-items: center;
}

.logo-area > a {
    height: 50px;
}

#site-logo-img {
    height: 50px;
    width: auto;
    margin-right: 10px;
}

.site-title {
    font-size: 1.5em;
    font-weight: bold;
    color: #1c1e21;
}

.main-nav ul {
    list-style: none;
    display: flex; /* Default desktop display */
    align-items: center;
}

.main-nav li {
    margin-left: 20px;
}

.main-nav li:first-child {
    margin-left: 0;
}

.main-nav a {
    color: #4b4f56;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    font-weight: 500;
}

.main-nav a:hover,
.main-nav a.active {
    background-color: #e7f3ff;
    color: #0056b3;
    text-decoration: none;
}

.nav-user-info {
    display: flex;
    align-items: center;
    margin-left: 25px;
    padding-left: 20px;
    border-left: 1px solid #e4e6eb;
}

.user-avatar-header {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
    border: 1px solid #ddd;
}

.welcome-message {
    font-size: 0.9em;
    color: #606770;
}

/* Burger Menu Button (Hidden on desktop by default) */
.burger-menu {
    display: none; /* Hidden by default, shown in responsive.css */
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1005;
}

.burger-menu .burger-bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #1c1e21;
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}


/* Login Page */
body.login-page-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%; /* Explicitly ensure full width */
    padding: 20px;
    background: url(/assets/imgs/dinosaur-background.webp) no-repeat center center fixed;
    background-size: cover;
    position: relative;
    margin: 0;
}

/* User Dashboard Page */
body.user-dashboard-body {
    background: url(/assets/imgs/dinosaur-background-dashboard.webp) no-repeat center center fixed;
    background-size: cover;
}
.user-dashboard-body .dashboard-header h1 {
    color: white;
}
.user-dashboard-body .dashboard-header #current-date {
    color: white;
}

/* Admin Dashboard Page */
body.admin-dashboard-body {
    background-image: url(/assets/imgs/dinosaur-admin-background.webp);
    background-size: contain;
}

.container-flex {
    display: flex;
    width: 100%;
    margin: 0 auto;
    padding: 20px 15px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
}
.login-container {
    width: 400px;
    max-width: 100%;
    padding: 30px 40px; 
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
}
.login-container h1 {
    margin-bottom: 25px;
    font-size: 28px;
    color: #0aa05d;
}
.login-container form div {
    margin-bottom: 18px;
    text-align: left;
}
.login-container label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 15px;
}
.login-container button {
    width: 100%;
    padding: 12px;
    background-color: #0aa05d;
    color: white;
    border: none;
    font-size: 18px;
    margin-top: 15px;
    transition: background-color 0.3s ease-in-out;
}
.login-container button:hover {
    background-color: #087b47;
}
.error-message, .feedback-message.error {
    color: #d93025;
    background-color: #fce8e6;
    border: 1px solid #fcc6c0;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 15px;
    min-height: 20px;
    text-align: left;
}
.feedback-message.success {
    color: #1e8e3e;
    background-color: #e6f4ea;
    border: 1px solid #c4e8d8;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 15px;
    text-align: left;
}


/* Dashboard Common */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e4e6eb;
}
.dashboard-header h1 {
    margin: 0;
    font-size: 24px;
}
.admin-list-container {
    margin-top: 20px;
}
#current-date {
    font-size: 1.1em;
    font-weight: 600;
    color: #606770;
}

/* User Dashboard - Column View */
#user-columns-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.user-column {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    padding: 15px;
    display: flex;
    flex-direction: column;
    border: 1px solid #e4e6eb;
}

.user-column .person-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid #e4e6eb;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
.person-avatar-display {
    margin-bottom: 8px;
}
.person-dashboard-avatar-ud {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e4e6eb;
}
.user-column .person-header h2 {
    margin: 5px 0 5px 0;
    font-size: 18px;
    color: #1c1e21;
    display: flex; /* To allow routine count to sit nicely */
    flex-wrap: wrap; /* Allow wrapping if name is too long */
    justify-content: center; /* Center items if they wrap */
    align-items: center;
}
/* User Dashboard - Routine Progress Count in Header */
.user-column .person-header .routine-progress-count {
    font-size: 0.8em; /* Smaller than the name */
    font-weight: normal;
    color: #555753; /* A slightly muted color */
    margin-left: 8px;
    white-space: nowrap; /* Prevent count from wrapping on its own */
}

.user-column .person-header .points {
    font-size: 16px;
    font-weight: 600;
    color: #1877f2;
}
.user-column .points .points-value {
    font-weight: bold;
}


.routine-item {
    display: flex;
    align-items: center;
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}
.routine-item:last-child {
    border-bottom: none;
}
.routine-item.completed {
    background-color: #e9f5e9;
}
.routine-item.completed label {
    text-decoration: line-through;
    color: #6c757d;
}
.routine-item.processing {
    opacity: 0.7;
    pointer-events: none;
}
.routine-checkbox {
    margin-right: 10px;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.routine-item label {
    display: flex;
    justify-content: space-between;
    flex-grow: 1;
    cursor: pointer;
    align-items: center;
}
.routine-display-number {
    font-weight: 500;
    color: #606770;
    margin-right: 5px; /* Space between number and title */
    min-width: 20px; /* Ensure some space for two-digit numbers */
    text-align: right;
}
.routine-title-text {
    margin-right: 8px;
    flex-grow: 1;
    font-size: 20px; /* Adjusted for consistency */
}
.routine-points {
    font-size: 15px; /* Adjusted for consistency */
    color: #007bff;
    white-space: nowrap;
    margin-left: auto;
    padding-left: 5px;
}
.no-routine-item {
    font-style: italic;
    color: #6c757d;
    padding: 10px 5px;
    text-align: center;
    list-style: none;
}

.rewards-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}
.rewards-section select {
    margin-bottom: 10px;
}
.claim-reward-btn {
    width: 100%;
    background-color: #42b72a;
    color: #fff;
}
.claim-reward-btn:hover {
    background-color: #36a420;
}
.claim-reward-btn:disabled {
    background-color: #e4e6eb;
    color: #bec3c9;
}

/* Admin Dashboard Sections */
.admin-section {
    background-color: #fff;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid #e4e6eb;
}
.admin-section h2 {
    margin-top: 0;
    font-size: 20px;
    color: #1c1e21;
    border-bottom: 1px solid #e4e6eb;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.admin-section form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
}
.admin-section form button[type="submit"] {
    background-color: #0aa05d;
    color: white;
    margin-top: 5px;
    min-width: 100px;
    transition: all 0.3s ease-in-out;
}
.admin-section form button[type="submit"]:hover {
    background-color: #087b47;
}

.admin-list ul, .admin-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.admin-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 5px;
    border-bottom: 1px solid #f0f2f5;
    font-size: 14px;
}
.admin-list li:last-child {
    border-bottom: none;
}
.admin-list .item-details {
    flex-grow: 1;
    margin-right: 15px;
    display: flex;
    align-items: center;
}
.person-dashboard-avatar-small {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 10px;
    border: 1px solid #ddd;
}
.admin-list .item-details .detail {
    font-size: 12px;
    color: #606770;
    margin-left: 10px;
    margin-right: 10px;
}
.admin-list .actions button {
    margin-left: 8px;
    padding: 4px 8px;
    font-size: 12px;
}
.edit-btn {
    background-color: #ffc107;
    color: #212529;
    transition: all 0.3s ease-in-out;
}
.edit-btn:hover {
    background-color: #e0a800;
}
.delete-btn {
    background-color: #dc3545;
    color: white;
    transition: all 0.3s ease-in-out;
}
.delete-btn:hover {
    background-color: #c82333;
}
.delete-all-btn {
    background-color: #dc3545;
    color: white;
    margin-top: 15px;
    transition: all 0.3s ease-in-out;
}
.delete-all-btn:hover {
    background-color: #c82333;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    margin: 10px auto;
    display: inline-block;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-placeholder {
    text-align: center;
    padding: 20px;
    color: #606770;
    font-style: italic;
}


/* --- Modal Styles --- */
.modal {
    display: none; /* Hidden by default, JS will toggle with .hidden class */
    position: fixed;
    z-index: 1050;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 15px;
}
.modal:not(.hidden) { /* When .hidden is removed, display as flex */
    display: flex;
}
.modal.hidden {
    display: none !important;
}
.modal-content {
    background-color: #fefefe;
    padding: 25px 30px;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 90%;
    max-width: 550px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    animation: fadeInModal 0.3s ease-out;
}
@keyframes fadeInModal {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.close-modal-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
}
.close-modal-btn:hover,
.close-modal-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
.modal-content h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.modal-content form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 14px;
}
.modal-content form input[type="text"],
.modal-content form input[type="password"],
.modal-content form input[type="number"],
.modal-content form input[type="file"],
.modal-content form select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
}
.modal-content form button[type="submit"],
.modal-actions button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    margin-top: 10px;
}
.modal-content form button[type="submit"]:hover,
.modal-actions button:hover {
    background-color: #0056b3;
}
.modal-actions .cancel-btn {
    background-color: #6c757d;
}
.modal-actions .cancel-btn:hover {
    background-color: #5a6268;
}
.modal-actions .delete-btn {
    background-color: #dc3545;
}
.modal-actions .delete-btn:hover {
    background-color: #c82333;
}
.modal-content .feedback-message {
    margin-top: 15px;
    font-size: 13px;
}

/* --- Reordering Styles (SortableJS) --- */
.sortable-list li {
    cursor: grab;
}
.drag-handle {
    cursor: grab;
    display: inline-block;
    font-weight: bold;
    color: #aaa;
    padding: 0 8px 0 0;
    font-size: 1.2em;
    align-self: center;
}
.drag-handle:active {
    cursor: grabbing;
}
.sortable-ghost {
    opacity: 0.4;
    background-color: #e7f3ff;
}
.sortable-chosen {
    cursor: grabbing;
    background-color: #f8f9fa;
}
.save-order-btn {
    padding: 8px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.save-order-btn:hover {
    background-color: #218838;
}
.save-order-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Toast messages for global feedback (if not using specific elements) */
.feedback-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 25px;
    border-radius: 6px;
    color: white;
    font-size: 1em;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    opacity: 0; /* Start hidden for fade-in */
    display: none; /* Start hidden */
    transition: opacity 0.5s ease;
}
.feedback-toast.success {
    background-color: #28a745;
}
.feedback-toast.error {
    background-color: #dc3545;
}

.item-details strong {
    padding-right: 5px;
}
.item-details small {
    padding: 0 5px;
}
