/* CSS Variables */
:root {
    --primary-color: #05386B;
    --secondary-color: #379683;
    --accent-color: #5CDB95;
    --light-accent: #8EE4AF;
    --background-color: #EDF5E1;
    --text-color: #05386B;
    --text-light: #379683;
    --white: #ffffff;
    --success: #5CDB95;
    --warning: #FFA726;
    --danger: #EF5350;
    --shadow: rgba(5, 56, 107, 0.1);
    --shadow-hover: rgba(5, 56, 107, 0.2);
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --gradient-primary: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    --gradient-accent: linear-gradient(135deg, var(--accent-color), var(--light-accent));
    --gradient-background: linear-gradient(135deg, var(--background-color), var(--white));
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #0D47A1;
    --secondary-color: #00695C;
    --accent-color: #4CAF50;
    --light-accent: #66BB6A;
    --background-color: #121212;
    --text-color: #E0E0E0;
    --text-light: #B0BEC5;
    --white: #1E1E1E;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    --gradient-background: linear-gradient(135deg, #121212, #1E1E1E);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--gradient-background);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: var(--gradient-primary);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: 0 2px 10px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--white);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
}

.nav-btn:hover,
.nav-btn.active {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-btn i {
    font-size: 1.2rem;
}

.theme-toggle {
    background: transparent;
    border: 2px solid var(--white);
    color: var(--white);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--white);
    color: var(--primary-color);
    transform: rotate(180deg);
}

/* Main Content */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2,
.section-header h3 {
    color: var(--primary-color);
    margin: 0;
}

/* Welcome Card */
.welcome-card {
    background: var(--gradient-accent);
    color: var(--white);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px var(--shadow);
}

.welcome-card h2 {
    color: var(--white);
    margin-bottom: 0.5rem;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 10px var(--shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
}

.stat-icon.clean {
    background: var(--success);
}

.stat-icon.warning {
    background: var(--warning);
}

.stat-icon.dirty {
    background: var(--danger);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Rooms Grid */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.room-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-accent);
}

.room-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.room-card.status-clean::before {
    background: var(--success);
}

.room-card.status-warning::before {
    background: var(--warning);
}

.room-card.status-dirty::before {
    background: var(--danger);
}

.room-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.room-icon {
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.room-info h3 {
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.room-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-indicator.clean {
    background: var(--success);
}

.status-indicator.warning {
    background: var(--warning);
}

.status-indicator.dirty {
    background: var(--danger);
}

.room-tasks {
    margin-top: 1rem;
}

.room-tasks h4 {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.task-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--background-color);
    font-size: 0.9rem;
}

.task-preview:last-child {
    border-bottom: none;
}

.task-name {
    color: var(--text-color);
}

.task-status {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Buttons */
.btn {
    background: var(--gradient-primary);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-hover);
}

.btn-secondary {
    background: var(--gradient-accent);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #D32F2F);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--background-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--text-color);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(92, 219, 149, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Filters */
.tasks-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.tasks-filters select {
    padding: 0.5rem;
    border: 2px solid var(--background-color);
    border-radius: var(--border-radius);
    background: var(--white);
    color: var(--text-color);
    min-width: 150px;
}

/* Tasks Container */
.tasks-container {
    display: grid;
    gap: 1rem;
}

.task-item {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.task-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.task-item.status-clean::before {
    background: var(--success);
}

.task-item.status-warning::before {
    background: var(--warning);
}

.task-item.status-dirty::before {
    background: var(--danger);
}

.task-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--shadow-hover);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.task-info h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

.task-actions {
    display: flex;
    gap: 0.5rem;
}

/* Next Tasks */
.next-tasks {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.tasks-list {
    display: grid;
    gap: 1rem;
}

.next-task {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.next-task:hover {
    background: var(--accent-color);
    color: var(--white);
}

.next-task-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.next-task-name {
    font-weight: 500;
}

.next-task-room {
    font-size: 0.9rem;
    opacity: 0.8;
}

.next-task-time {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Residents */
.residents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.resident-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
    text-align: center;
    transition: var(--transition);
}

.resident-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.resident-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--white);
    font-weight: bold;
}

.resident-name {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.resident-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.resident-stat {
    text-align: center;
}

.resident-stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.resident-stat-label {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Ranking */
.ranking-section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.ranking-list {
    display: grid;
    gap: 1rem;
}

.ranking-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.ranking-item:hover {
    background: var(--accent-color);
    color: var(--white);
}

.ranking-position {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.ranking-position.first {
    background: linear-gradient(135deg, #FFD700, #FFA000);
}

.ranking-position.second {
    background: linear-gradient(135deg, #C0C0C0, #9E9E9E);
}

.ranking-position.third {
    background: linear-gradient(135deg, #CD7F32, #8D6E63);
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.ranking-score {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.chart-container h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.summary-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px var(--shadow);
    transition: var(--transition);
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px var(--shadow-hover);
}

.summary-card h4 {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.summary-number {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.summary-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.setting-group {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: 0 2px 10px var(--shadow);
}

.setting-group h3 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--background-color);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    flex: 1;
    margin-bottom: 0;
}

.setting-item input[type="number"],
.setting-item input[type="time"] {
    width: auto;
    min-width: 120px;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: var(--transition);
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--white);
    border-radius: var(--border-radius);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid var(--background-color);
}

.modal-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.modal-content form {
    padding: 1.5rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 20px var(--shadow);
    border-left: 4px solid var(--accent-color);
    max-width: 300px;
    animation: toastSlideIn 0.3s ease-out;
    transition: var(--transition);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-message {
    flex: 1;
    color: var(--text-color);
}

/* Loading Spinner */
.loading-spinner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 4000;
    align-items: center;
    justify-content: center;
}

.loading-spinner.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--background-color);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.footer {
    background: var(--gradient-primary);
    color: var(--white);
    text-align: center;
    padding: 1rem 0;
    margin-top: 2rem;
}

.footer p {
    margin: 0;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        justify-content: center;
        width: 100%;
    }

    .nav-btn {
        flex: 1;
        min-width: 0;
    }

    .nav-btn span {
        display: none;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .quick-stats {
        grid-template-columns: 1fr;
    }

    .rooms-grid {
        grid-template-columns: 1fr;
    }

    .tasks-filters {
        flex-direction: column;
    }

    .tasks-filters select {
        min-width: auto;
    }

    .task-header {
        flex-direction: column;
        gap: 1rem;
    }

    .task-actions {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        min-width: 0;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .setting-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .residents-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }

    .toast-container {
        left: 20px;
        right: 20px;
    }

    .toast {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .main {
        padding: 1rem 0;
    }

    .welcome-card {
        padding: 1.5rem;
    }

    .room-card,
    .task-item,
    .resident-card {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .summary-number {
        font-size: 2rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .nav,
    .btn,
    .modal,
    .toast-container,
    .loading-spinner {
        display: none !important;
    }

    .main {
        padding: 0;
    }

    .section {
        display: block !important;
        page-break-before: always;
    }

    .section:first-child {
        page-break-before: auto;
    }

    body {
        background: white !important;
        color: black !important;
    }

    .room-card,
    .task-item,
    .stat-card {
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --shadow: rgba(0, 0, 0, 0.5);
        --shadow-hover: rgba(0, 0, 0, 0.7);
    }

    .btn,
    .room-card,
    .task-item,
    .stat-card {
        border: 2px solid var(--text-color);
    }
}
