:root {
    --primary: #0096c7;
    --primary-dark: #0077b6;
    --secondary: #48cae4;
    --bg-color: #f0f4f8;
    --card-bg: #ffffff;
    --text-color: #2b2d42;
    --text-light: #8d99ae;
    --success: #2a9d8f;
    --danger: #ef233c;
    --warning: #ffb703;
    --sidebar-width: 260px;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --blue: #0096c7;
    /* Fix for missing variable */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    padding: 2rem;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.02);
    z-index: 10;
}

.brand {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.3s ease;
    text-align: left;
}

.nav-btn:hover {
    background-color: rgba(0, 150, 199, 0.05);
    color: var(--primary);
    transform: translateX(4px);
}

.nav-btn.active {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 150, 199, 0.3);
}

/* Status Card */
.status-card {
    background-color: #f8f9fa;
    padding: 1.2rem;
    border-radius: var(--radius);
    text-align: center;
    margin-top: auto;
}

.status-header {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 0.8rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-indicator.connected {
    background-color: rgba(42, 157, 143, 0.1);
    color: var(--success);
}

.status-indicator.disconnected {
    background-color: rgba(239, 35, 60, 0.1);
    color: var(--danger);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.4;
    }
}

.qr-btn {
    margin-top: 1rem;
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--primary);
    background: transparent;
    color: var(--primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}

.qr-btn:hover {
    background: var(--primary);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.view-header h1 {
    font-size: 1.8rem;
    color: var(--text-color);
}

.search-box {
    background: white;
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 300px;
}

.search-box input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
}

.search-box i {
    color: var(--text-light);
}

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue {
    background: rgba(0, 150, 199, 0.1);
    color: var(--primary);
}

.stat-icon.green {
    background: rgba(42, 157, 143, 0.1);
    color: var(--success);
}

.stat-icon.red {
    background: rgba(239, 35, 60, 0.1);
    color: var(--danger);
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.stat-info span {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Table */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
    padding-bottom: 5rem;
    /* Extra space for badges/actions */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
    min-width: 800px;
    /* Ensure table doesn't shrink too much */
}

th,
td {
    padding: 1rem;
    text-align: left;
    white-space: nowrap;
    /* Prevent wrapping causing layout shifts */
    border-bottom: 1px solid #f0f0f0;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.9rem;
}

td {
    color: var(--text-color);
}

tr:hover {
    background-color: #f8f9fa;
}

/* Badges */
.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-active {
    background: rgba(42, 157, 143, 0.1);
    color: var(--success);
}

.badge-overdue {
    background: rgba(239, 35, 60, 0.1);
    color: var(--danger);
}

.badge-upcoming {
    background: rgba(255, 183, 3, 0.1);
    color: var(--warning);
}

/* Buttons */
.icon-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: 0.2s;
    font-size: 1rem;
}

.icon-btn.edit {
    color: var(--primary);
}

.icon-btn.edit:hover {
    background: rgba(0, 150, 199, 0.1);
}

.icon-btn.delete {
    color: var(--danger);
}

.icon-btn.delete:hover {
    background: rgba(239, 35, 60, 0.1);
}

.icon-btn.whatsapp {
    color: #25D366;
}

.icon-btn.whatsapp:hover {
    background: rgba(37, 211, 102, 0.1);
}

/* Form Styles */
.form-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 800px;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: 0.3s;
    font-family: inherit;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 150, 199, 0.1);
}

.submit-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: 0.3s;
}

.submit-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    text-align: center;
    max-width: 400px;
    position: relative;
    animation: zoomIn 0.3s;
}

.modal-content table {
    min-width: auto;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
}

#qr-image {
    max-width: 100%;
    margin: 1.5rem 0;
    border: 1px solid #eee;
    padding: 1rem;
    border-radius: 8px;
}

/* Admin Page Theme Overrides */
body.admin-page {
    --primary: #2c3e50;
    --secondary: #e74c3c;
}

body.admin-page .sidebar {
    background-color: var(--primary);
}

/* Login Page Styles */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background: #f8f9fa;
    overflow: auto;
    /* Reset overflow from main body rule if needed */
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-page .brand {
    justify-content: center;
    margin-bottom: 2rem;
    color: #4361ee;
    /* Specific login primary color if desired, or use var(--primary) */
}

.login-page .form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.login-page .btn {
    width: 100%;
    padding: 12px;
    background: #4361ee;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.login-page .btn:hover {
    background: #3f37c9;
    transform: translateY(-2px);
}

.login-page .error {
    color: #ef233c;
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}