:root {
    --sidebar-width: 260px;
    --primary-color: #4e73df;
    --secondary-color: #858796;
    --success-color: #1cc88a;
    --info-color: #36b9cc;
    --warning-color: #f6c23e;
    --danger-color: #e74a3b;
    --dark-bg: #1a1c23;
    --sidebar-bg: #2c3e50;
    --main-bg: #f8f9fc;
    --text-main: #5a5c69;
    --card-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-main);
    min-height: 100vh;
}

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu a {
    padding: 12px 25px;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: 0.3s;
    font-size: 0.95rem;
}

.sidebar-menu a i {
    width: 20px;
    margin-right: 15px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left: 4px solid var(--primary-color);
}

.sidebar-footer a {
    padding: 12px 25px;
    display: flex;
    align-items: center;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: 0.3s;
    font-size: 0.95rem;
    border-radius: 4px;
}

.sidebar-footer a i {
    width: 20px;
    margin-right: 15px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-footer a:hover {
    background: var(--danger-color);
    color: white;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 25px;
    width: calc(100% - var(--sidebar-width));
}

.top-bar {
    background: white;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 25px;
    margin: -25px -25px 25px -25px;
    box-shadow: 0 .15rem 1.75rem 0 rgba(58,59,69,.15);
    position: sticky;
    top: 0;
    z-index: 990;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.95);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.timeout-indicator {
    font-size: 0.85rem;
    color: var(--secondary-color);
    background: #f8f9fc;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #e3e6f0;
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.blink {
    animation: blink 1s infinite;
}

/* Dashboard Cards */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 20px;
    margin-bottom: 25px;
    border: none;
}

.card-header {
    border-bottom: 1px solid #e3e6f0;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
}

/* Forms in Dashboard */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: .5rem;
    font-size: .85rem;
    font-weight: 700;
    color: #4e73df;
}

.form-control {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #6e707e;
    background-color: #fff;
    border: 1px solid #d1d3e2;
    border-radius: .35rem;
    box-sizing: border-box;
}

.form-control:focus {
    border-color: #bac8f3;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(78,115,223,.25);
}

/* Tables in Dashboard */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background-color: #f8f9fc;
    color: var(--text-main);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    padding: 12px 15px;
    border-bottom: 2px solid #e3e6f0;
    text-align: left;
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e3e6f0;
    font-size: 0.9rem;
}

table tr:hover {
    background-color: #f8f9fc;
}

/* Sortable Headers */
.sortable-header {
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.sortable-header:hover {
    background-color: #eaecf4 !important;
}

.sortable-header a {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: 0.2s;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: #2e59d9; }
.btn-success { background: var(--success-color); color: white; }
.btn-danger { background: var(--danger-color); color: white; }
.btn-info { background: var(--info-color); color: white; }
.btn-warning { background: var(--warning-color); color: white; }
.btn-warning:hover { background: #f4b619; }
.btn-secondary { background: var(--secondary-color); color: white; }
.btn-secondary:hover { background: #717384; }

/* Filter Section */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: #f8f9fc;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

/* Stats Widgets */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-left: 4px solid var(--primary-color);
    border-radius: 5px;
    padding: 15px 20px;
    box-shadow: var(--card-shadow);
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #5a5c69;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
}

@media (max-width: 767.98px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        transition: left 0.3s ease;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
        display: flex !important;
    }

    .sidebar.show {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .top-bar {
        margin: -25px -25px 25px -25px;
        padding: 0 15px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block !important;
    }
}

/* Timeout Indicator */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.timeout-indicator {
    background: #f8f9fc;
    border: 1px solid #e3e6f0;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #858796;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.timeout-indicator i {
    font-size: 0.8rem;
}

.blink {
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% { opacity: 0.3; }
}

/* Switch Toggle Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.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: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4e73df;
}

input:focus + .slider {
    box-shadow: 0 0 1px #4e73df;
}

input:checked + .slider:before {
    transform: translateX(20px);
}
