:root {
    --am-primary: #4f46e5;
    --am-primary-soft: #eef2ff;
    --am-bg: #f3f4f6;
    --am-card-bg: #ffffff;
    --am-text-main: #1f2937;
    --am-text-muted: #6b7280;
    --am-border: #e5e7eb;
    --am-radius: 16px;
    --am-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Reset de estilos del contenedor principal para evitar espacios */
.main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Corregir el contenedor padre si tiene flex */
.dashboard-container {
    align-items: flex-start !important;
}

.access-manager-container {
    display: flex;
    height: calc(100vh - 100px);
    background: var(--am-bg);
    gap: 20px;
    padding: 0;
    margin-top: 10px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Sidebar de Usuarios */
.am-users-sidebar {
    width: 300px;
    background: var(--am-card-bg);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--am-border);
}

.am-sidebar-header {
    padding: 20px;
    background: var(--am-card-bg);
    border-bottom: 1px solid var(--am-border);
}

.am-sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--am-text-main);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.am-search-box {
    position: relative;
}

.am-search-box input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--am-border);
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    background: #f9fafb;
    color: var(--am-text-main);
}

.am-search-box input:focus {
    border-color: var(--am-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.am-search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--am-text-muted);
}

.am-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.am-user-item {
    display: flex;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin-bottom: 6px;
    border: 1px solid transparent;
}

.am-user-item:hover {
    background: #f9fafb;
    border-color: var(--am-border);
}

.am-user-item.active {
    background: var(--am-primary-soft);
    border-color: #c7d2fe;
}

.am-user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--am-primary);
    margin-right: 12px;
    font-size: 14px;
    flex-shrink: 0;
}

.am-user-item.active .am-user-avatar {
    background: linear-gradient(135deg, var(--am-primary) 0%, #4338ca 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(79, 70, 229, 0.25);
}

.am-user-info {
    flex: 1;
    min-width: 0; /* Text truncation fix */
}

.am-user-name {
    font-weight: 600;
    color: var(--am-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.am-user-item.active .am-user-name {
    color: var(--am-primary);
}

.am-user-role {
    font-size: 0.75rem;
    color: var(--am-text-muted);
    margin-top: 2px;
}

/* Panel Principal */
.am-main-panel {
    flex: 1;
    background: var(--am-card-bg);
    border-radius: var(--am-radius);
    box-shadow: var(--am-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--am-border);
}

.am-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--am-text-muted);
    text-align: center;
    padding: 40px;
}

.am-empty-state i {
    font-size: 48px;
    margin-bottom: 20px;
    color: #d1d5db;
    background: #f3f4f6;
    padding: 24px;
    border-radius: 50%;
}

.am-panel-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--am-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.am-panel-title h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--am-text-main);
    font-weight: 700;
}

.am-panel-title span {
    color: var(--am-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

.am-save-btn {
    background: var(--am-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.am-save-btn:hover {
    background: #4338ca;
    transform: translateY(-1px);
}

.am-permissions-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: #f9fafb;
}

.am-permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    align-content: start;
}

/* Tarjetas de Permisos Mejoradas */
.am-card {
    background: white;
    border: 1px solid var(--am-border);
    border-radius: 12px;
    transition: all 0.2s ease;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.am-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.05);
    border-color: #d1d5db;
}

.am-card.active-group {
    border-color: var(--am-primary);
    box-shadow: 0 0 0 1px var(--am-primary), 0 4px 6px rgba(79, 70, 229, 0.1);
}

.am-card-header {
    padding: 16px;
    border-bottom: 1px solid var(--am-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    cursor: pointer;
    user-select: none;
}

.am-card-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--am-text-main);
    font-size: 0.95rem;
}

.am-card-icon {
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--am-text-muted);
    transition: all 0.2s;
}

.am-card.active-group .am-card-icon {
    background: var(--am-primary-soft);
    color: var(--am-primary);
}

.am-card-body {
    padding: 0;
    background: #fff;
}

.am-permission-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.am-permission-item:hover {
    background: #f9fafb;
}

.am-permission-item:last-child {
    border-bottom: none;
}

.am-perm-label {
    font-size: 0.9rem;
    color: var(--am-text-main);
    font-weight: 500;
}

/* Toggle Switch iOS Style */
.am-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.am-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.am-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e5e7eb;
    transition: .3s ease;
    border-radius: 34px;
}

.am-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

input:checked + .am-slider {
    background-color: var(--am-primary);
}

input:checked + .am-slider:before {
    transform: translateX(20px);
}

/* Badge de conteo */
.am-count-badge {
    font-size: 0.75rem;
    background: #f3f4f6;
    color: var(--am-text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
    margin-right: 12px;
    font-weight: 600;
}

.am-card.active-group .am-count-badge {
    background: var(--am-primary-soft);
    color: var(--am-primary);
}

/* Scrollbar personalizado */
.am-users-list::-webkit-scrollbar,
.am-permissions-content::-webkit-scrollbar {
    width: 6px;
}

.am-users-list::-webkit-scrollbar-track,
.am-permissions-content::-webkit-scrollbar-track {
    background: transparent;
}

.am-users-list::-webkit-scrollbar-thumb,
.am-permissions-content::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 20px;
}

.am-users-list::-webkit-scrollbar-thumb:hover,
.am-permissions-content::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}