:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --text-main: #334155;
    --text-light: #64748b;
    --white: #ffffff;
    --border-color: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.03);
    --shadow-medium: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: #0f172a;
    font-weight: 600;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: all 0.3s ease;
}

/* Form Elements */
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: var(--bg-color);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    background-color: var(--white);
}

button, .btn {
    display: inline-block;
    padding: 12px 24px;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

button:hover, .btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.sidebar {
    width: 280px;
    background-color: var(--white);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
    border-top-right-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    margin-right: 20px;
}

.sidebar-header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-size: 22px;
    letter-spacing: -0.5px;
}

.sidebar-menu {
    padding: 20px 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-menu ul {
    list-style: none;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
    border-left-color: var(--primary-color);
}

.sidebar-menu li a i {
    margin-right: 12px;
    font-size: 18px;
}

.main-content {
    flex: 1;
    padding: 30px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
}

/* Top Header */
.top-header {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    box-shadow: var(--shadow-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.menu-toggle {
    display: none;
    font-size: 24px;
    color: var(--text-main);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
}

.menu-toggle:hover {
    background: none;
    box-shadow: none;
    color: var(--primary-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

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

/* Cards */
.card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.3s ease;
    min-width: 0;
    max-width: 100%;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

/* Global Footer */
.global-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 14px;
    margin-top: auto;
}

.global-footer span {
    font-weight: 600;
    color: var(--text-main);
}

/* Auth Pages (Login) */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.auth-card {
    background-color: var(--white);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h1 {
    color: var(--primary-color);
    font-size: 28px;
    margin-bottom: 10px;
}

.auth-header p {
    color: var(--text-light);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-main);
    font-size: 14px;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    cursor: pointer;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}
.table th, .table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
.table th {
    background-color: #f8fafc;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
}
.table tbody tr {
    transition: all 0.2s ease;
}
.table tbody tr:hover {
    background-color: #f1f5f9;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    padding: 30px;
    margin: 20px;
}
.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}
.modal-header h2 {
    font-size: 20px;
    margin: 0;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
}
.modal-close:hover {
    color: var(--danger);
    background: none;
    box-shadow: none;
    transform: none;
}
.d-none { display: none !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 16px; }

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
}
.badge-blue { background-color: #e0f2fe; color: #0369a1; }
.badge-purple { background-color: #f3e8ff; color: #7e22ce; }

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    padding: 0;
}
.btn-edit { background-color: #f59e0b; }
.btn-edit:hover { background-color: #d97706; transform: translateY(-1px); }
.btn-delete { background-color: var(--danger); }
.btn-delete:hover { background-color: #b91c1c; transform: translateY(-1px); }

/* search bar */
.search-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.search-input {
    min-width: 250px;
    flex: 1;
}

/* Responsive 100% Mobile Compatible */
@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        bottom: 0;
        margin-right: 0;
        border-radius: 0;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .top-header {
        margin-bottom: 20px;
    }
    
    /* Overlay for mobile sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0,0,0,0.4);
        z-index: 99;
        display: none;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 767px) {
    /* Mobile Layout Fixes */
    .card.d-flex.justify-between.align-center {
        flex-direction: column;
        align-items: stretch;
    }
    .search-container {
        flex-direction: column;
        width: 100%;
    }
    .search-input {
        width: 100%;
        min-width: 0;
    }
    .search-container form {
        display: flex;
        width: 100%;
    }
    .search-container form input {
        flex: 1;
        min-width: 0;
    }
    .search-container > .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Avoid Nested Cards Issue */
    .card.p-0 {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Tables to Cards */
    .table-responsive {
        overflow: visible;
        border: none;
        padding: 0;
        width: 100%;
    }
    .table thead {
        display: none;
    }
    .table tbody, .table tr, .table td {
        display: block;
        width: 100%;
    }
    .table tr {
        margin-bottom: 20px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background-color: var(--white);
        box-shadow: var(--shadow-soft);
        padding: 0;
    }
    .table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        border-bottom: 1px solid #f1f5f9;
        padding: 14px 16px;
        word-break: break-word;
    }
    .table td:last-child {
        border-bottom: none;
        flex-direction: row;
        justify-content: flex-end;
        align-items: center;
        background-color: #f8fafc;
        border-bottom-left-radius: var(--radius-md);
        border-bottom-right-radius: var(--radius-md);
        padding: 12px 16px;
    }
    .table td:last-child::before {
        display: none;
    }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-light);
        margin-bottom: 6px;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .table td > div {
        text-align: left;
    }
    .modal {
        padding: 24px 20px;
        margin: auto;
        width: calc(100% - 32px);
    }
}
