/* Admin Responsive & Layout Fixes */
:root {
    --sidebar-width: 250px;
    --header-height: 60px;
    --primary-color: #3498db;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
}

/* Global Reset for Admin */
* {
    box-sizing: border-box;
}

body {
    overflow-x: hidden; /* Prevent horizontal scroll on body */
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Main Layout Wrapper */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0; /* Never shrink */
    background: #2c3e50;
    color: #fff;
    padding: 20px;
    transition: width 0.3s;
}

.admin-sidebar h2 {
    margin-bottom: 30px;
    color: #fff;
}

.admin-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-sidebar li {
    margin-bottom: 15px;
}

.admin-sidebar a {
    color: #aaa;
    text-decoration: none;
    display: block;
    transition: color 0.2s;
}

.admin-sidebar a:hover, .admin-sidebar a.active {
    color: #fff;
}

/* Content Area */
.admin-content {
    flex: 1;
    min-width: 0; /* Crucial: allows flex child to shrink smaller than its content */
    padding: 30px;
    background: #f5f7fa;
    overflow-x: hidden; /* Prevent internal spillover */
    width: 100%; /* Ensure it fills available space */
}

/* Cards & Panels */
.card, .panel {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

/* Responsive Grids */
.grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    width: 100%;
}

.grid-2-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    width: 100%;
}

/* Responsive Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Scroll internally if absolutely necessary */
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    /* table-layout: fixed; */ /* Removed fixed layout to allow columns to size naturally if possible, or use min-width */
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    white-space: nowrap; /* Headers can stay on one line usually */
}

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-active, .badge-success { background: #d4edda; color: #155724; }
.badge-blocked, .badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-admin, .badge-info { background: #cce5ff; color: #004085; }

/* Buttons */
.btn {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s;
}
.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}
.btn-primary:hover { background-color: #2980b9; }

.btn-danger {
    background-color: var(--danger-color);
    color: #fff;
}
.btn-danger:hover { background-color: #c0392b; }

.btn-secondary {
    background-color: #95a5a6;
    color: #fff;
}
.btn-secondary:hover { background-color: #7f8c8d; }

/* Action Buttons (Icons) */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
    margin-right: 5px;
    transition: transform 0.2s;
}
.action-btn:hover { transform: scale(1.1); }
.btn-block { color: var(--danger-color); }
.btn-unblock { color: var(--success-color); }
.btn-reset { color: var(--warning-color); }

/* Stat Cards (Icon Layout) */
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}
.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    flex-shrink: 0;
}
.stat-info h3 { margin: 0; font-size: 24px; color: #333; }
.stat-info p { margin: 0; color: #777; font-size: 14px; }

/* Severity Badges */
.severity-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    display: inline-block;
}
.severity-high { background-color: #e67e22; }
.severity-critical { background-color: #c0392b; }
.severity-medium { background-color: #f1c40f; color: #333; }
.severity-low, .severity-info { background-color: #3498db; }

/* Checkbox Column */
.checkbox-col { width: 40px; text-align: center; }

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filters input, .filters select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.filters button {
    padding: 8px 15px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.filters button:hover { background: #2980b9; }

/* Alert Items (Security Dashboard) */
.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    border-bottom: 1px solid #eee;
    gap: 15px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.alert-content {
    flex: 1;
    min-width: 200px;
}

.alert-actions {
    flex-shrink: 0;
    text-align: right;
    font-size: 12px;
    color: #999;
}

/* Inputs and Forms */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
select,
textarea {
    max-width: 100%; /* Prevent inputs from overflowing containers */
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    overflow-x: auto;
    white-space: nowrap;
}
.nav-tab { 
    padding: 10px 20px; 
    text-decoration: none; 
    color: #555; 
    border-radius: 4px; 
    font-weight: 500;
}
.nav-tab.active { background-color: #2c3e50; color: #fff; }
.nav-tab:hover:not(.active) { background-color: #ecf0f1; }

/* Media Queries */
@media (max-width: 768px) {
    .admin-wrapper {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        padding: 15px;
    }
    
    .admin-content {
        padding: 15px;
    }

    .grid-2-col {
        grid-template-columns: 1fr;
    }
    
    th, td {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters input, .filters select, .filters button {
        width: 100%;
    }
}
