/* Reset + base */
* {
    box-sizing: border-box;
}

:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --muted: #6b7280;
    --accent: #4f46e5;
    --accent-2: #06b6d4;
    --card-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    --radius: 12px;
    --text: #0f172a;
}

html,
body {
    height: 100%;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    color: var(--text);
    background: var(--bg);
}

/* Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    gap: 24px;
    padding: 20px;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    padding: 22px;
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    justify-content:start;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    display: block;
}

.brand h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.2px;
}

.brand small {
    display: block;
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: all .18s ease;
    font-size: 14px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: transparent;
}

.search-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-wrap input[type="search"] {
    width: 420px;
    max-width: 60vw;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: var(--panel);
    box-shadow: var(--card-shadow);
    outline: none;
}

.search-wrap button {
    padding: 10px 12px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    color: white;
    font-weight: 600;
}

/* Top-right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-inline {
    background: linear-gradient(90deg, #fff 0, #fff 100%);
    padding: 8px 12px;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.stat-num {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
}

.profile {
    display: flex;
    gap: 8px;
    align-items: center;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.username {
    font-weight: 600;
    color: var(--muted);
}

/* Cards */
.cards {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.card {
    flex: 1;
    background: var(--panel);
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
}

.card-title {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

/* Sections */
.content-section {
    background: transparent;
    padding: 8px 0;
    display: none;
}

.content-section.active {
    display: block;
}

/* Table wrap */
.table-wrap {
    background: var(--panel);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--card-shadow);
    overflow: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

/* Mobile table wrapper */
@media (max-width: 768px) {
    .table-wrap {
        padding: 8px;
        border-radius: 8px;
    }
    
    .table-wrap::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-wrap::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .table-wrap::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 4px;
    }
    
    .table-wrap::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.styled-table thead th {
    text-align: left;
    padding: 12px;
    font-weight: 700;
    font-size: 13px;
    color: var(--muted);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), rgba(15, 23, 42, 0.01));
    position: sticky;
    top: 0;
}

.styled-table tbody td {
    padding: 12px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    vertical-align: middle;
    color: var(--text);
}

.styled-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.03), rgba(6, 182, 212, 0.01));
}

/* Badges */
.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(79, 70, 229, 0.08);
    color: var(--accent);
}

/* Actions */
.btn, .contact-view-btn {
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.contact-view-btn {
    background: var(--accent);
    color: white;
    margin-right: 8px;
}

.contact-view-btn:hover {
    background: #4338ca;
}

/* Touch-friendly buttons */
@media (max-width: 768px) {
    .btn, .btn-edit, .btn-delete, .btn-cancel, .btn-save, .btn-delete-confirm, .btn-logout-confirm, .contact-view-btn {
        min-height: 44px; /* Minimum touch target size */
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .page-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

.btn-ghost {
    background: transparent;
    color: white;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.action-btn {
    background: transparent;
    border: 1px solid rgba(15, 23, 42, 0.06);
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
}

/* Table controls & pagination */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 12px;
}

.pagination {
    display: flex;
    gap: 8px;
    align-items: center;
}

.page-btn {
    padding: 6px 10px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid rgba(15, 23, 42, 0.06);
    cursor: pointer;
}

/* modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.4);
}

.modal[aria-hidden="false"] {
    display: flex;
}

.modal-panel {
    width: 520px;
    max-width: 92%;
    background: var(--panel);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    position: relative;
}

.modal-close {
    position: absolute;
    right: 12px;
    top: 8px;
    border: none;
    background: transparent;
    font-size: 22px;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard-layout {
        padding: 15px;
        gap: 20px;
    }
    
    .sidebar {
        width: 240px;
    }
    
    .search-wrap input[type="search"] {
        width: 350px;
    }
}

@media (max-width: 1024px) {
    .dashboard-layout {
        padding: 12px;
        gap: 15px;
    }
    
    .sidebar {
        width: 220px;
        padding: 18px;
    }
    
    .search-wrap input[type="search"] {
        width: 300px;
    }
    
    .modal-panel {
        width: 90%;
        max-width: 500px;
    }
}

@media (max-width: 900px) {
    .dashboard-layout {
        padding: 12px;
        flex-direction: column;
        gap: 15px;
    }

    .sidebar {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px;
        border-radius: 10px;
        order: 2;
    }

    .main {
        order: 1;
        margin-top: 0;
    }

    .search-wrap {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .search-wrap input[type="search"] {
        width: 100%;
        max-width: none;
    }

    .topbar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .topbar-right {
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .cards {
        flex-direction: column;
        gap: 10px;
    }

    .styled-table {
        min-width: 600px;
        font-size: 14px;
    }
    
    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
        padding: 0 5px;
    }
    
    .team-card img {
        width: 90px;
        height: 90px;
    }

    .team-actions {
        flex-direction: column;
        gap: 5px;
    }

    .btn-edit, .btn-delete {
        width: 100%;
        padding: 8px 12px;
    }

    .modal-panel {
        width: 95%;
        max-width: 450px;
        margin: 5% auto;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        padding: 8px;
    }

    .sidebar {
        padding: 10px;
        gap: 8px;
    }

    .brand h2 {
        font-size: 16px;
    }

    .brand small {
        font-size: 11px;
    }

    .nav {
        gap: 4px;
    }

    .nav-link {
        padding: 8px 10px;
        font-size: 13px;
    }

    .search-wrap input[type="search"] {
        padding: 8px 12px;
        font-size: 14px;
    }

    .search-wrap button {
        padding: 8px 10px;
        font-size: 13px;
    }

    .stat-inline {
        padding: 6px 10px;
        font-size: 12px;
    }

    .stat-num {
        font-size: 14px;
    }

    .card {
        padding: 12px;
    }

    .card-title {
        font-size: 12px;
    }

    .card-value {
        font-size: 18px;
    }

    .styled-table {
        min-width: 500px;
        font-size: 12px;
    }

    .styled-table thead th,
    .styled-table tbody td {
        padding: 8px;
    }

    .table-controls {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .pagination {
        justify-content: center;
    }

    .page-btn {
        padding: 4px 8px;
        font-size: 12px;
    }

    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .team-card {
        padding: 12px;
    }
    
    .team-card img {
        width: 70px;
        height: 70px;
    }

    .team-card h3 {
        font-size: 14px;
        margin: 8px 0 4px 0;
    }

    .team-card p {
        font-size: 12px;
    }

    #team-form {
        flex-direction: column;
        gap: 8px;
    }

    #team-form input,
    #team-form button {
        padding: 10px;
        font-size: 14px;
    }

    .modal-panel {
        width: 98%;
        max-width: 400px;
        margin: 2% auto;
        padding: 15px;
    }

    .modal-header {
        padding: 20px 15px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-body {
        padding: 20px 15px;
    }

    .form-group input[type="text"],
    .form-group input[type="email"] {
        padding: 12px 15px;
        font-size: 14px;
    }

    .btn-cancel, .btn-save, .btn-delete-confirm, .btn-logout-confirm {
        padding: 10px 16px;
        font-size: 13px;
    }

    .modal-actions {
        flex-direction: column;
        gap: 8px;
    }

    .modal-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-layout {
        padding: 5px;
    }

    .sidebar {
        padding: 8px;
        flex-direction: column;
        text-align: center;
    }

    .brand {
        flex-direction: column;
        gap: 8px;
    }

    .nav {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-link {
        padding: 6px 8px;
        font-size: 12px;
        flex: 1;
        min-width: 80px;
        text-align: center;
    }

    .search-wrap input[type="search"] {
        padding: 6px 10px;
        font-size: 13px;
    }

    .search-wrap button {
        padding: 6px 8px;
        font-size: 12px;
    }

    .topbar-right {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }

    .profile {
        flex-direction: column;
        gap: 4px;
        text-align: center;
    }

    .avatar {
        width: 30px;
        height: 30px;
    }

    .username {
        font-size: 12px;
    }

    .card {
        padding: 10px;
    }

    .card-title {
        font-size: 11px;
    }

    .card-value {
        font-size: 16px;
    }

    .styled-table {
        min-width: 400px;
        font-size: 11px;
    }

    .styled-table thead th,
    .styled-table tbody td {
        padding: 6px 4px;
    }

    .team-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .team-card {
        padding: 8px;
    }
    
    .team-card img {
        width: 60px;
        height: 60px;
    }

    .team-card h3 {
        font-size: 12px;
        margin: 6px 0 3px 0;
    }

    .team-card p {
        font-size: 10px;
    }

    .team-actions {
        gap: 4px;
    }

    .btn-edit, .btn-delete {
        padding: 6px 8px;
        font-size: 10px;
    }

    .modal-panel {
        width: 100%;
        margin: 1% auto;
        padding: 10px;
        border-radius: 15px;
    }

    .modal-header {
        padding: 15px 10px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .close-btn {
        width: 35px;
        height: 35px;
        font-size: 24px;
    }

    .modal-body {
        padding: 15px 10px;
    }

    .form-group input[type="text"],
    .form-group input[type="email"] {
        padding: 10px 12px;
        font-size: 13px;
    }

    .btn-cancel, .btn-save, .btn-delete-confirm, .btn-logout-confirm {
        padding: 8px 12px;
        font-size: 12px;
    }

    .logout-icon {
        font-size: 36px;
        margin-bottom: 15px;
    }

    #logout-modal h2 {
        font-size: 20px;
    }

    #logout-modal p {
        font-size: 13px;
    }
}

/* Landscape orientation for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .dashboard-layout {
        flex-direction: row;
    }

    .sidebar {
        width: 200px;
        flex-direction: column;
        align-items: stretch;
    }

    .nav {
        flex-direction: column;
    }

    .main {
        margin-top: 0;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .topbar,
    .modal,
    .btn,
    .team-actions {
        display: none !important;
    }

    .dashboard-layout {
        flex-direction: column;
        padding: 0;
    }

    .main {
        width: 100%;
    }

    .styled-table {
        font-size: 12px;
    }
}

/* Team Section */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 20px;
    padding: 0 10px;
}

.team-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.team-card:hover {
    transform: translateY(-5px);
}

.team-card img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 10px;
    max-width: 100%;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#team-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#team-form input,
#team-form button {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

#team-form button {
    background: #3498db;
    color: white;
    cursor: pointer;
}

#team-form button:hover {
    background: #2980b9;
}

/* Team Actions */
.team-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-edit, .btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-edit {
    background: #3498db;
    color: white;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-cancel, .btn-save, .btn-delete-confirm {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancel {
    background: #95a5a6;
    color: white;
}

.btn-cancel:hover {
    background: #7f8c8d;
}

.btn-save {
    background: #27ae60;
    color: white;
}

.btn-save:hover {
    background: #229954;
}

.btn-delete-confirm {
    background: #e74c3c;
    color: white;
}

.btn-delete-confirm:hover {
    background: #c0392b;
}

/* Form styling in modals */
#team-update-form input[type="text"],
#team-update-form input[type="file"] {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.image-preview {
    text-align: center;
}

.warning-text {
    color: #e74c3c;
    font-weight: 600;
    margin: 10px 0;
}

/* User Details Modal */
.user-detail-item {
    margin: 12px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

.user-detail-item:last-child {
    border-bottom: none;
}

.user-detail-item strong {
    color: var(--accent);
    display: inline-block;
    min-width: 120px;
    margin-right: 10px;
}

/* Logout Modal Styles */
.logout-icon {
    font-size: 48px;
    text-align: center;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.btn-logout-confirm {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-logout-confirm:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.btn-logout-confirm:active {
    transform: translateY(0);
}

#logout-modal .modal-panel {
    text-align: center;
    max-width: 400px;
}

#logout-modal h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 24px;
}

#logout-modal p {
    color: #7f8c8d;
    margin-bottom: 10px;
    line-height: 1.6;
}

#logout-modal .warning-text {
    color: #e74c3c;
    font-weight: 600;
    font-size: 14px;
}


/* Dark mode (toggled by JS adding .dark on body) */
body.dark {
    --bg: #06070a;
    --panel: #0b1220;
    --muted: #9ca3af;
    --accent: #7c3aed;
    --accent-2: #0891b2;
    --text: #e6eef8;
}